Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is int(a) an expression and int(unsigned(a)) a type-id in the example below?

In [dcl.ambig.res]/2 we find the following:

void foo(signed char a) {
    sizeof(int(a)); // expression
    sizeof(int(unsigned(a))); // type-id (ill-formed)
}

Why is int(a) an expression and int(unsigned(a)) a type-id?

At first sight I would say that both are expressions.

like image 319
Alexander Avatar asked Mar 28 '18 22:03

Alexander


1 Answers

int(unsigned(a)) is parsed the same as int(unsigned a), which is a function type

like image 198
Justin Avatar answered Nov 07 '22 08:11

Justin