[Bug c++/13613] New: enumerator conflict from enclosing namespace

mdorey at bluearc dot com gcc-bugzilla@gcc.gnu.org
Thu Jan 8 14:49:00 GMT 2004


enum A {
  B
};
namespace C {
  enum D {
    B
  };
}

Now produces:

enumerator-namespace-3.3.3-regression.cpp:7: error: conflicting types for `B'
enumerator-namespace-3.3.3-regression.cpp:3: error: previous declaration as `A 
   B'

When I think it should compile as do at least some previous gcc versions.

The above error was from:

gcc -v -c enumerator-namespace-3.3.3-regression.cpp 
Reading specs from /usr/lib/gcc-lib/i486-linux/3.3.3/specs
Configured with: ../src/configure -v --enable-
languages=c,c++,java,f77,pascal,objc,ada,treelang --prefix=/usr --
mandir=/usr/share/man --infodir=/usr/share/info --with-gxx-include-
dir=/usr/include/c++/3.3 --enable-shared --with-system-zlib --enable-nls --
without-included-gettext --enable-__cxa_atexit --enable-clocale=gnu --enable-
debug --enable-java-gc=boehm --enable-java-awt=xlib --enable-objc-gc i486-linux
Thread model: posix
gcc version 3.3.3 20031229 (prerelease) (Debian)
 /usr/lib/gcc-lib/i486-linux/3.3.3/cc1plus -quiet -v -D__GNUC__=3 -
D__GNUC_MINOR__=3 -D__GNUC_PATCHLEVEL__=3 -D_GNU_SOURCE enumerator-namespace-
3.3.3-regression.cpp -D__GNUG__=3 -quiet -dumpbase enumerator-namespace-3.3.3-
regression.cpp -auxbase enumerator-namespace-3.3.3-regression -version -
o /tmp/ccciZdLn.s
GNU C++ version 3.3.3 20031229 (prerelease) (Debian) (i486-linux)
        compiled by GNU C version 3.3.3 20031229 (prerelease) (Debian).
GGC heuristics: --param ggc-min-expand=98 --param ggc-min-heapsize=129171
ignoring nonexistent directory "/usr/i486-linux/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/include/c++/3.3
 /usr/include/c++/3.3/i486-linux
 /usr/include/c++/3.3/backward
 /usr/local/include
 /usr/lib/gcc-lib/i486-linux/3.3.3/include
 /usr/include
End of search list.

And I know it compiles OK on:

gcc -v -c enumerator-namespace-3.3.3-regression.cpp 
Reading specs from /usr/lib/gcc-lib/i486-linux/3.3.2/specs
Configured with: ../src/configure -v --enable-
languages=c,c++,java,f77,pascal,objc,ada,treelang --prefix=/usr --
mandir=/usr/share/man --infodir=/usr/share/info --with-gxx-include-
dir=/usr/include/c++/3.3 --enable-shared --with-system-zlib --enable-nls --
without-included-gettext --enable-__cxa_atexit --enable-clocale=gnu --enable-
debug --enable-java-gc=boehm --enable-java-awt=xlib --enable-objc-gc i486-linux
Thread model: posix
gcc version 3.3.2 20030831 (Debian prerelease)
 /usr/lib/gcc-lib/i486-linux/3.3.2/cc1plus -quiet -v -D__GNUC__=3 -
D__GNUC_MINOR__=3 -D__GNUC_PATCHLEVEL__=2 -D_GNU_SOURCE enumerator-namespace-
3.3.3-regression.cpp -D__GNUG__=3 -quiet -dumpbase enumerator-namespace-3.3.3-
regression.cpp -auxbase enumerator-namespace-3.3.3-regression -version -
o /tmp/ccv9ZMlX.s
GNU C++ version 3.3.2 20030831 (Debian prerelease) (i486-linux)
        compiled by GNU C version 3.3.2 20030831 (Debian prerelease).
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
ignoring nonexistent directory "/usr/i486-linux/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/include/c++/3.3
 /usr/include/c++/3.3/i486-linux
 /usr/include/c++/3.3/backward
 /usr/local/include
 /usr/lib/gcc-lib/i486-linux/3.3.2/include
 /usr/include
End of search list.
 as -V -Qy -o enumerator-namespace-3.3.3-regression.o /tmp/ccv9ZMlX.s
GNU assembler version 2.14.90.0.7 (i386-linux) using BFD version 2.14.90.0.7 
20031029 Debian GNU/Linux

So I'm thinking that this is a regression in 3.3.3 over 3.3.2.

Perhaps one relevant sentence from the Standard is from 7.2.10: The enum-name 
and each enumerator declared by an enum-specifier is declared in the scope that 
immediately contains the enum-specifier.

-- 
           Summary: enumerator conflict from enclosing namespace
           Product: gcc
           Version: 3.3.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: mdorey at bluearc dot com
                CC: gcc-bugs at gcc dot gnu dot org


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



More information about the Gcc-bugs mailing list