This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/28044] New: Non-template class function return type taken as template when declared in a function template's return type
- From: "widman at gimpel dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 15 Jun 2006 18:07:42 -0000
- Subject: [Bug c++/28044] New: Non-template class function return type taken as template when declared in a function template's return type
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
See below; G++ appears to correctly handle the use of 'struct B' to declare the
function template g(), but if there is no prior declaration of the class (as in
the declaration of f()), the class is erroneously taken as a class template.
extern "C" int printf( const char*, ... );
struct B{ int n; B(int n_) : n(n_){} };
template<class T> struct B g() // OK, g() returns B
{
return B(32);
}
template<class T> struct A f(); // OK, f() returns A
struct A { char c; A(char c_) : c(c_){}};
template<class T> struct A f()
{
return A('x');
}
int main( )
{
(void) printf( "%d, %c\n",
g<double>().n,
f<float>().c ); // prints "32, x\n".
return 0;
}
--
Summary: Non-template class function return type taken as
template when declared in a function template's return
type
Product: gcc
Version: 4.0.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: widman at gimpel dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28044