[Bug c++/55776] New: -Wshadow generates an incorrect warning with enum classes

sefi@s-e-f-i.de gcc-bugzilla@gcc.gnu.org
Fri Dec 21 16:25:00 GMT 2012


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

             Bug #: 55776
           Summary: -Wshadow generates an incorrect warning with enum
                    classes
    Classification: Unclassified
           Product: gcc
           Version: 4.7.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: sefi@s-e-f-i.de


In C++11 mode, enum classes can generate incorrect -Wshadow warnings:

g++ -Wshadow -std=c++11 test.cpp

typedef int foo;

enum class myenum
{
        foo
};

test.cpp:5:2: warning: declaration of 'foo' shadows a global declaration
[-Wshadow]
test.cpp:1:13: warning: shadowed declaration is here [-Wshadow]


Note, that if the typedef and the definition of the enum class are reversed, no
warning is produced.



More information about the Gcc-bugs mailing list