[Bug c++/60994] New: gcc does not recognize hidden/shadowed enumeration as valid nested-name-specifier
momchil.velikov at gmail dot com
gcc-bugzilla@gcc.gnu.org
Tue Apr 29 07:00:00 GMT 2014
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60994
Bug ID: 60994
Summary: gcc does not recognize hidden/shadowed enumeration as
valid nested-name-specifier
Product: gcc
Version: 4.10.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: momchil.velikov at gmail dot com
gcc version 4.10.0 20140428 (experimental) (GCC)
Compiling (with c++ -c -std=c++11 b.cc) the following program
enum struct A
{
n = 3
};
int
foo()
{
int A;
return A::n;
}
results in the error:
b.cc: In function 'int foo()':
b.cc:10:10: error: 'A' is not a class, namespace, or enumeration
return A::n;
^
According to the C++11 Standard, [basic.lookup.qual] #1
"If a :: scope resolution operator in a nested-name-specifier is not preceded
by a decltype-specifier, lookup of the name preceding that :: considers only
namespaces, types, and templates whose specializations are types."
GCC ought not to resolve "A" to the local variable, but to the enumeration
type. This is very similar to the example in the standard
struct A
{
static int n;
};
int
foo()
{
int A;
return A::n;
}
which is compiled correctly by GCC, though.
More information about the Gcc-bugs
mailing list