------- Comment #2 from sc09q4 at bullseye dot com 2009-11-13 21:04 ------- Let's look at these tokens "T()(int())" in detail.
(1) Yes "T()" looks like a function declarator: T()(int()) 111 (2) Then follows something in parenthesis, which looks a lot like C++03 direct-declarator rule #2, also indicating a function declarator: T()(int()) 1112 2 (3) But what about the tokens inside those parenthesis - "int()"? That is not a valid parameter-declaration-clause: T()(int()) 1112333332 So these tokens do not form a declarator at all. The problem is not semantic but rather syntactic. (4) Now consider the context. The tokens above, appear inside an if-statement, inside extra parenthesis: if (( T()(int()) )) 44 44 1112333332 44 There is no C++ grammar rule that allows a declarator inside "if(( ))". It must be an expression. Now consider the discrepancy of how GCC handles these two statements: if ( T()(int()) ) ; if ((T()(int()))) ; The first compiles successfully. The tokens in the if-statement condition are understood as an expression. But in the second statement, an error is reported. But the only difference is that expression is parenthesized. Merely parenthesizing an expression ought not cause a compiler to complain that expression is not a valid type. Still not convinced? Consider the behavior of some other compilers. I tested with Microsoft C++ v15, Intel C++ v9, PC-Lint v9, and GCC v3.4.6. They all compile this program without error. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42034