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

            Bug ID: 78825
           Summary: missing error for template partial specialization
                    using template alias type
           Product: gcc
           Version: 5.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: mattia.bonaducci at gmail dot com
  Target Milestone: ---

With GCC 5.1 it was possible to compile such code without errors of warnings.

---
template <typename T>
struct C;

template<typename T>
using first = T;

template <typename T>
struct C<first<T>>  // OK only in 5.1
{
};

int main ()
{
}
---

Before and after 5.1 it yields "partial specialization 'C<T>' does not
specialize any template arguments". By that I assume it was regression fixed in
next version. Now by slightly modifying this code we can still compile it
without any warnings or errors.

---
template <typename T>
struct C;

template<typename T1, typename T2>
using first = T1;

template<typename T1, typename T2>
using second = T2;

template <typename T>
struct C<first<T, T>>  // OK on 5.1+
{
};

template <typename T>
struct C<second<T, T>>  // OK on 5.1+
{
};

int main ()
{
        //C<first<int, int>> dummy; // error: ambiguous template instantiation
for 'struct C<int>'
}
---
First error we get is when we try to use it. It looks like there is no way of
explicitly pointing to one of this specializations. This problem showed up with
GCC 5 and is still in 6 and 7 snapshot. 

Here's how I checked different compiler versions (-std=c++14 -O0 -Wall -Wextra)
https://godbolt.org/g/1uV80Z

Reply via email to