Bug 84832 - Base class member function incorrectly introduced by using-declarator
Summary: Base class member function incorrectly introduced by using-declarator
Status: NEW
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 7.3.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: accepts-invalid
Depends on:
Blocks:
 
Reported: 2018-03-12 14:56 UTC by Jaak Ristioja
Modified: 2024-01-09 04:14 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail: 4.4.7
Last reconfirmed: 2021-08-03 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jaak Ristioja 2018-03-12 14:56:20 UTC
struct Base {
    template <typename T, int = 42>
    void f(T &&) const {}
};

struct Derived: Base {
    template <typename T, typename X = typename T::asdf>
    void f(T &&) const {}

    using Base::f;
};

int main() {
    Derived const cd;
    cd.f('x');
}

The following compiles fine with GCC and -std=c++11, but not with Clang. User liliscent over at https://stackoverflow.com/q/49235124/3919155 thinks this is a GCC bug, because Base::f should not be introduced by the using-declarator because of [namespace.udecl]:

> When a using-declarator brings declarations from a
> base class into a derived class, member functions
> and member function templates in the derived class
> override and/or hide member functions and member
> function templates with the same name, parameter-
> type-list, cv-qualification, and ref-qualifier (if
> any) in a base class (rather than conflicting).
> Such hidden or overridden declarations are excluded
> from the set of declarations introduced by the
> using-declarator.
Comment 1 Jonathan Wakely 2018-03-12 16:57:57 UTC
EDG also accepts the code. I'm confirming this as an accepts-invalid bug, but it's possible this is a defect in the standard instead and GCC and EDG are doing the right thing.
Comment 2 Andrew Pinski 2021-08-04 04:39:00 UTC
Note GCC and ICC accept the code.
While clang and MSVC reject the code.