This question is inspired by Is sizeof(void()) a legal expression? but with an important difference as explained below.
The expression in question is:
No, sizeof( int() )
is ill-formed because int()
is taken to be a type-id. Specifically, it's a function type, and sizeof
cannot be applied to a function type.
[dcl.ambig.res]/2:
An ambiguity can arise from the similarity between a function-style cast and a type-id. The resolution is that any construct that could possibly be a type-id in its syntactic context shall be considered a type-id.
with this exact example given:
void foo(signed char a) { sizeof(int()); // type-id (ill-formed) sizeof(int(a)); // expression sizeof(int(unsigned(a))); // type-id (ill-formed)