[Bug c++/53154] New: Template class not shadowed by member declaration

amonakov at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Sat Apr 28 11:29:00 GMT 2012


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53154

             Bug #: 53154
           Summary: Template class not shadowed by member declaration
    Classification: Unclassified
           Product: gcc
           Version: 4.8.0
            Status: UNCONFIRMED
          Keywords: accepts-invalid
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: amonakov@gcc.gnu.org


The following code is unexpectedly accepted without any warning:

template<int> struct foo {static const int bar=1;};
struct baz {static const int foo=foo<0>::bar;};

When foo is not template, GCC diagnoses the shadowing as expected:

struct foo {static const int bar=1;};
struct baz {static const int foo=foo::bar;};

<stdin>:2:39: error: declaration of ‘const int baz::foo’ [-fpermissive]
<stdin>:1:8: error: changes meaning of ‘foo’ from ‘struct foo’ [-fpermissive]

4.5, 4.6, 4.7 and trunk behave the same.



More information about the Gcc-bugs mailing list