https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101789
Bug ID: 101789
Summary: Fails to match (re-)declaration of member function of
class template when using an alias template for the
(dependent) return type
Product: gcc
Version: 11.1.0
Status: UNCONFIRMED
Keywords: rejects-valid
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: davveston at gmail dot com
Target Milestone: ---
(Broken out into a separate report, from my comment to Bug 69348, after prompt
by Andrew Pinski)
---
The following program
template<typename T>
struct S {
using type = int;
type f() const; // #1
};
template<typename T>
using type_t = typename S<T>::type;
template <typename T>
type_t<T> S<T>::f() const { } // #2a
// error: no declaration matches 'type_t<T> S<T>::f() const'
int main() {}
is rejected e.g. for GCC 11.1.0 for all C++ versions (-std=c++X with X in {11,
17, 2a/2b}), failing to match the (re-)declaration and definition at #2a of the
member function of the class template at #1, when using an alias template for
the dependent return type of the member function. Clang accepts this program.
The program is accepted if we remove the alias template
template <typename T>
typename S<T>::type S<T>::f() const { } // #2b: OK