[Bug c++/60994] 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:21:00 GMT 2014


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

--- Comment #3 from Momchil Velikov <momchil.velikov at gmail dot com> ---
(In reply to Markus Trippelsdorf from comment #1)
> Implicit enum to int conversion is not provided for a scoped enumeration.

This is not the reported error.

In fact, the correct output of the compiler would be to report the invalid
implicit conversion. It does not.

With explicit conversion to int, the compiler still gives an error, but the
error message is not helpful and obscures the cause of the problem, i.e.,
compiling this:

enum struct A
{
  n = 3
};

int
foo()
{
  int A;
  return int(A::n);
}

results in:


b.cc: In function 'int foo()':
b.cc:10:10: error: expected primary-expression before 'int'
   return int(A::n);
          ^
b.cc:10:10: error: expected ';' before 'int'
b.cc:10:10: error: expected primary-expression before 'int'



More information about the Gcc-bugs mailing list