[Bug c++/58898] New: Adding default template argument causes to class template compile error
evgeny.panasyuk at gmail dot com
gcc-bugzilla@gcc.gnu.org
Mon Oct 28 01:03:00 GMT 2013
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58898
Bug ID: 58898
Summary: Adding default template argument causes to class
template compile error
Product: gcc
Version: 4.8.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: evgeny.panasyuk at gmail dot com
Following code fails to compile on GCC 4.8.1, but compiles OK and Clang 3.4 and
MSVC2010.
Live demo: http://coliru.stacked-crooked.com/a/5fa616a7f18e2485
/***************************/
template <typename = int>
struct Foo
{
Foo()
{
int t(int()); // Error
}
};
int main()
{
int t(int()); // OK
Foo<> a; // Error
}
/***************************/
main.cpp: In constructor 'Foo< <template-parameter-1-1> >::Foo()':
main.cpp:6:20: error: default argument for template parameter for class
enclosing 'int t(int (*)())'
int t(int()); // Error
^
main.cpp: In function 'int main()':
main.cpp:13:9: error: wrong number of template arguments (0, should be 1)
Foo<> a; // Error
^
main.cpp:2:8: error: provided for 'template<class> struct Foo'
struct Foo
^
main.cpp:13:12: error: invalid type in declaration before ';' token
Foo<> a; // Error
^
/***************************/
But following code compiles OK.
Live demo: http://coliru.stacked-crooked.com/a/3e6c7f85f2ee5615
template <typename>
struct Foo
{
Foo()
{
int t(int()); // OK
}
};
int main()
{
int t(int()); // OK
Foo<int> a; // OK
}
/***************************/
Original case was in StackOverflow Question:
http://stackoverflow.com/questions/19625314/inheriting-from-a-class-template-with-a-default-argument/19625343#19625343
More information about the Gcc-bugs
mailing list