Alexander
Alexander

Reputation: 2591

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.

Upvotes: 7

Views: 197

Answers (1)

Justin
Justin

Reputation: 25377

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

Upvotes: 8

Related Questions