Bug 78308 - Hiding of member function templates introduced by using-decl
Summary: Hiding of member function templates introduced by using-decl
Status: NEW
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 7.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: accepts-invalid
Depends on:
Blocks:
 
Reported: 2016-11-11 10:00 UTC by Axel Naumann
Modified: 2021-08-05 08:24 UTC (History)
2 users (show)

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


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Axel Naumann 2016-11-11 10:00:04 UTC
Hi,

struct A {
  template <class T> auto func(T t) -> decltype(T::member);
};

struct B: A {
  using A::func;
  template <class T> auto func(T t) -> decltype(T::other);
};

struct P { int member; };

void call(B b, P p) {
  b.func(p);
}


GCC accepts this; ICC and clang reject this, refusing to introduce A::func in B. See also [namespace.udecl](15):

"When a using-declaration 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 (8.3.5),
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-declaration."

Cheers, Axel.
Comment 1 TC 2017-03-24 18:44:35 UTC
A rejects-valid case:

struct C {
    template<int> void f();
};

struct D : C {
    template<char> void f();
    using C::f;
};

int main(){
    D().f<0>();
}

GCC rejects as ambiguous, Clang accepts as it only considers the template<char> one.
Comment 2 Jonathan Wakely 2019-07-13 22:27:42 UTC
GCC now accepts comment 1, but still accepts comment 0.