[Bug c++/100335] New: Using statement of a ref-qualified method from base class: method not callable on derived object
Daniel.Withopf at web dot de
gcc-bugzilla@gcc.gnu.org
Thu Apr 29 14:48:23 GMT 2021
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100335
Bug ID: 100335
Summary: Using statement of a ref-qualified method from base
class: method not callable on derived object
Product: gcc
Version: 10.3.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: Daniel.Withopf at web dot de
Target Milestone: ---
The following code examples defines 2 ref-qualified method with identical names
in a base class (const& and const&&). Derived also defines a (non-const) method
with the same name and adds a "using Base::method;"
With all gcc Versions I tested (10.3, 9.3, 8.3, 7.5), the compilation with
--std=c++11 or --std=c++14 fails if the method in the derived class does not
have a ref-qualifier.
class Base {
public:
void method() const&& {}
void method() const& {}
};
class Derived : public Base {
public:
using Base::method;
// this leads to a compiler error
void method() {}
// with a ref-qualifier the code is compiling
// void method() & {}
};
int main() {
const Derived test;
test.method();
}
I believe that this is incorrect and the code should also compile when the
method in the Derived class has no ref-qualifier.
More information about the Gcc-bugs
mailing list