Bug 81398 - Complaining about 'partial specialization of '...' after instantiation' in c++1z
Summary: Complaining about 'partial specialization of '...' after instantiation' in c++1z
Status: RESOLVED INVALID
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 8.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-07-11 16:52 UTC by d25fe0be@
Modified: 2017-09-27 13:15 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description d25fe0be@ 2017-07-11 16:52:07 UTC
GCC7/8 fails to compile the following code:

```
template <class T, class U=double> struct X {};
typedef X<int, double> Xint; // `typedef X<int> Xint` fails to compile with the same error.
template <class U> struct Y {};
Y<Xint> abc;
template <template <class> class TT, class T> struct Y<TT<T>> {};

int main() {}
```

with:

```
./a.cpp:5:54: error: partial specialization of 'struct Y<TT<T> >' after instantiation of 'struct Y<X<int, double> >' [-fpermissiv]
 template <template <class> class TT, class T> struct Y<TT<T>> {};
```

if `-std=c++1z` is specified.

Compiling with `-std=c++14` works fine.

Removing the default argument of template parameter `U` of class `X`, or defaulting `U` to some other type rather than `double` (the second argument used in typedef'ing `Xint`) makes the code to compile.

It seems that the default argument of template parameter somehow removes the corresponding template parameter from what GCC concerns when doing pattern matching. 

GCC6 compiles the code, whether '-std=c++14' or '-std=c++1z' is specified. 
Clang compiles the code as well.
Comment 1 TC 2017-08-09 20:03:13 UTC
This is the result of DR 150/P0522R0.
Comment 2 d25fe0be@ 2017-09-27 13:15:53 UTC
Let's close it then. Sorry for the noise.