g++ accepts a type as a template argument, that is defined inside of an unnamed type. In the attached example t_inner is defined in an unnamed structure. That would make t_inner a "type compounded from an unnamed type" as I read section 14.3.1-2 of the ISO/IEC 14882/1998 standard (p. 241). So this should cause an error (and does with other Compilers / tools), but g++ accepts it. The problem was found with: > gcc -v Using built-in specs. Target: sparc-sun-solaris2.10 Configured with: ../gcc-4.2.4/configure --prefix=/usr/local/gcc424 Thread model: posix gcc version 4.2.4 It has also been verified with: > gcc -v Reading specs from /usr/local/gcc344/lib/gcc/sparc-sun-solaris2.10/3.4.4/specs Configured with: ./configure --prefix=/usr/local/gcc344 Thread model: posix gcc version 3.4.4 It has also been seen with version 4.3.3 on Linux (Ubuntu 9.04 on 64bit Intel). The Comeau online compiler gives an "a template argument may not reference an unnamed type" error message for that code.
Created attachment 18806 [details] (almost) minimal example A g++ -pedantic -ansi -Wall -Wextra -o ArrayWithInnerStructure3 ArrayWithInnerStructure3.cpp ; ./ArrayWithInnerStructure3 ; echo $? just prints "8" and no compilation error or warning.
In the C++11 times I don't think we are going to work on this .. Are we?
I believe that "unnamed type" here was not meant to include a nested type in a class with a name. EDG disagrees, so I'm suspending the PR until the committee rules on this case.
Do we have DR # for this issue?
DR 62 clarified that G++ is correct here. http://open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#62
(In reply to Jason Merrill from comment #5) > DR 62 clarified that G++ is correct here. > > http://open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#62 Actually, it didn't really; this case is still unclear in the new wording for DR 62.