https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66879

--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Anders Granlund from comment #0)
> Note that if we remove the member function definition in the given program
> it compiles without errors.

I think that's the real bug. G++ should not accept this program:

class A;

namespace Y {
    using ::A;
    class A { };
}

int main()
{
  Y::A a;
  ::A* p = &a;
}

Clang rejects it because Y::A in main() is ambiguous, but EDG rejects it with
the same error as for the original testcase:

"a.cc", line 5: error: class "A" cannot be defined in the current scope
      class A { };
            ^

I believe EDG is right to reject that class-specifier because the class name A
has already been introduced into that scope, and it cannot be a definition of
::A because it doesn't use a nested-name-specifier and it isn't in the
namespace (or an enclosing namespace) of ::A.

Reply via email to