c++/6190: T::C.X is accepted, although it should read T::C::X

reichelt@igpm.rwth-aachen.de reichelt@igpm.rwth-aachen.de
Fri Apr 5 09:46:00 GMT 2002


>Number:         6190
>Category:       c++
>Synopsis:       T::C.X is accepted, although it should read T::C::X
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          accepts-illegal
>Submitter-Id:   net
>Arrival-Date:   Fri Apr 05 09:46:01 PST 2002
>Closed-Date:
>Last-Modified:
>Originator:     Volker Reichelt
>Release:        gcc version 3.1 20020325 (prerelease)
>Organization:
>Environment:
i686-pc-linux-gnu, mips-sgi-irix6.5
>Description:
The following code, although illegal, is accepted by g++
(even with -Wall -W -pedantic turned on):

----------------------------snip here-----------
struct A { enum { X=4 }; };
struct B { typedef A C; };
template <class T> int foo () { return T::C.X; } // wrong, should be T::C::X
int main() { return foo<B>(); }
----------------------------snip here-----------

Note that the correct version is also accepted by g++.
(This is at least better than 2.95.x and 3.0.x which
accepted the illegal version and rejected the legal one.)

B::C.X is rejected as it should be.
>How-To-Repeat:
g++ bug.cpp
>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:



More information about the Gcc-prs mailing list