http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56886
Bug #: 56886
Summary: [4.9 regression] undesirable instantiation of class
template default argument
Classification: Unclassified
Product: gcc
Version: 4.9.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: [email protected]
ReportedBy: [email protected]
The following code compiles with GCC 4.8 and earlier:
template <typename T>
struct A
{
typedef typename T::type type;
};
template <typename T, typename U = A<int>()>
struct C;
template <typename T>
struct C<T>
{
};
C<int> c;
but fails to compile with GCC 4.9 (2013-04-07 snapshot) with the following
error:
test.cpp: In instantiation of 'struct A<int>':
test.cpp:16:8: required from here
test.cpp:4:30: error: 'int' is not a class, struct, or union type
typedef typename T::type type;
^
It seems that GCC 4.9 is instantiating A<int>, the return type of the function
type A<int>() which is the default argument for C's template parameter U, while
GCC 4.8 and earlier was not instantiating this class.
The error also has something to do with the presence of the partial
specialization of C, because removing it (and giving the primary template a
definition instead) makes it go away.