https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87570

            Bug ID: 87570
           Summary: Rejects valid alias template usage (as a type pack
                    size requirement)
           Product: gcc
           Version: 9.0
            Status: UNCONFIRMED
          Keywords: rejects-valid
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: nok.raven at gmail dot com
  Target Milestone: ---

MWE:
----
template <typename T, typename...>
using limit_argnum = T;

template <typename... T>
struct tuple
{
    template <typename... U>
    tuple(limit_argnum<U, T>&&...) {}
};

tuple<int, long> a(1, 2);


GCC says:
---------
<source>:11:24: error: no matching function for call to 'tuple<int, long
int>::tuple(int, int)'
11 | tuple<int, long> a(1, 2);
   |                        ^
<source>:8:5: note: candidate: 'template<class ... U>
tuple<T>::tuple(limit_argnum<U, T>&& ...)'
8 |     tuple(limit_argnum<U, T>&&...) {}
  |     ^~~~~
<source>:8:5: note:   template argument deduction/substitution failed:
<source>:11:24: note:   mismatched types 'limit_argnum<U, T>' and 'int'
11 | tuple<int, long> a(1, 2);
   |                        ^
<source>:5:8: note: candidate: 'constexpr tuple<int, long int>::tuple(const
tuple<int, long int>&)'
5 | struct tuple
  |        ^~~~~
<source>:5:8: note:   candidate expects 1 argument, 2 provided
<source>:5:8: note: candidate: 'constexpr tuple<int, long
int>::tuple(tuple<int, long int>&&)'
<source>:5:8: note:   candidate expects 1 argument, 2 provided


Note that the same thing but with a function works:
---------------------------------------------------
template <typename T, typename...>
using limit_argnum = T;

template <typename... T, typename... U>
void foo(limit_argnum<U, T>&&...) {}

int main()
{
    foo<int, long>(1, 2);
}


Clang and MSVC are fine with both examples.

Reply via email to