http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56421
Bug #: 56421
Summary: Non-matching overload produces template substitution
error
Classification: Unclassified
Product: gcc
Version: 4.7.2
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: [email protected]
ReportedBy: [email protected]
template<class S> struct Foo {
typedef typename S::type type;
};
template<class> void foo();
template<class S> typename Foo<S>::type foo(int);
int main()
{
foo<int>();
}
Produces the following error in both gcc-4.7.2 and gcc-4.6.3:
$ g++ -c t.cpp
t.cpp: In instantiation of ‘struct Foo<int>’:
t.cpp:6:41: required by substitution of ‘template<class S> typename Foo::type
foo(int) [with S = int]’
t.cpp:10:12: required from here
t.cpp:2:28: error: ‘int’ is not a class, struct, or union type
Clang accepts it as valid.
Note: No errors are reported by GCC if we change line 6 from
template<class S> typename Foo<S>::type foo(int);
to
template<class S> typename S::type foo(int);