This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/66879] Error message when defining a member function inside a class definition
- From: "redi at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 15 Jul 2015 15:31:18 +0000
- Subject: [Bug c++/66879] Error message when defining a member function inside a class definition
- Auto-submitted: auto-generated
- References: <bug-66879-4 at http dot gcc dot gnu dot org/bugzilla/>
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.