[Bug c++/100335] New: Using statement of a ref-qualified method from base class: method not callable on derived object
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.
[Bug c++/100335] Using statement of a ref-qualified method from base class: method not callable on derived object
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100335 --- Comment #2 from Daniel --- As an extra Info: the other compilers I tested (e.g. clang) accept the code example as is. But after reading the cited pet of the standard It seems that GCC is right in rejecting this and the other compilers have an issue.
[Bug c++/100335] Using statement of a ref-qualified method from base class: method not callable on derived object
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100335 --- Comment #5 from Daniel --- As a sidenote, the original example is also compiling if test object is made non-const, i.e. "const Derived test;" is replaced with "Derived test;" If the argument in Comment 1 is true than the program would still be ill-formed in this case, wouldn't it?
[Bug c++/100335] Using statement of a ref-qualified method from base class: method not callable on derived object
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100335 --- Comment #7 from Daniel --- To me it seems that [over.load] is the right section of the standard as the start of the section explicitly mentions that the rules there (either all or none of the overloads must have ref-qualifiers) applies when a using declaration is involved: "Not all function declarations can be overloaded. Those that cannot be overloaded are specified here. A program is ill-formed if it contains two such non-overloadable declarations in the same scope. [Note:This restriction applies to explicit declarations in a scope, and between such declarations and declarations made through a using-declaration(7.3.3). It does not apply to sets of functions fabricated as a result of name lookup (e.g., because of using-directives) or overload resolution (e.g., for operator functions).— end note]" Could it be that - gcc is on the right track by rejecting the example, but it should also reject the code in the case where the offending method is not called (see Comment 6)? - clang, MSVC are not taking the above note into consideration and thus are missing an error in this case?