Strange code that compiles with g++

According to the C++ Standard (p. #6 of section 7 Declarations)

6 Each init-declarator in the init-declarator-list contains exactly
one declarator-id
, which is the name declared by that
init-declarator and hence one of the names declared by the declaration

So it is simply a compiler bug.

The valid code could look as for example (apart from the function pointer declaration showed by you) though I can not compile it with my MS VC++ 2010.

int(*p){};

It seems that the compiler you are using for testing allows declarations without a declarator-id.

Also take into account the following paragraph of section 8.1 Type names

1 To specify type conversions explicitly, and as an argument of
sizeof, alignof, new, or typeid, the name of a type shall be
specified. This can be done with a type-id, which is syntactically a
declaration for a variable or function of that type that omits the
name of the entity.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)