[Bug c++/84709] Cannot define method with same name of previously using declared class
redi at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Mon Mar 5 12:23:00 GMT 2018
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84709
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |rejects-valid
Status|UNCONFIRMED |RESOLVED
Resolution|--- |INVALID
--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Proper testcase that actually shows the error:
namespace A {
class Foo {
};
}
using A::Foo;
namespace B {
class Bar {
const Foo &Foo() const;
};
}
hide.cc:10:22: error: declaration of ‘const A::Foo& B::Bar::Foo() const’
[-fpermissive]
const Foo &Foo() const;
^~~~~
hide.cc:2:9: error: changes meaning of ‘Foo’ from ‘class A::Foo’ [-fpermissive]
class Foo {
^~~
Which can be reduced to:
struct Foo { };
struct Bar {
const Foo &Foo() const;
};
The member function B::Bar::foo does hide ::Foo, and that violates
[basic.scope.class]/2.
More information about the Gcc-bugs
mailing list