Bug 41725 - g++ accepts compounded unnamed type in template (violates 14.3.1-2)
Summary: g++ accepts compounded unnamed type in template (violates 14.3.1-2)
Status: SUSPENDED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.2.4
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: accepts-invalid
Depends on:
Blocks:
 
Reported: 2009-10-16 08:46 UTC by Thomas Dorner
Modified: 2021-09-13 17:09 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2011-09-29 00:00:00


Attachments
(almost) minimal example (283 bytes, text/plain)
2009-10-16 08:59 UTC, Thomas Dorner
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Thomas Dorner 2009-10-16 08:46:35 UTC
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.
Comment 1 Thomas Dorner 2009-10-16 08:59:39 UTC
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.
Comment 2 Paolo Carlini 2011-09-28 21:28:34 UTC
In the C++11 times I don't think we are going to work on this .. Are we?
Comment 3 Jason Merrill 2011-09-29 00:17:53 UTC
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.
Comment 4 Paolo Carlini 2013-06-10 09:38:37 UTC
Do we have DR # for this issue?
Comment 5 Jason Merrill 2013-06-10 15:59:53 UTC
DR 62 clarified that G++ is correct here.

http://open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#62
Comment 6 Jason Merrill 2013-06-10 16:02:59 UTC
(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.