This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/32993] New: Template type dedution of funtion reference includes default args
- From: "gianni at mariani dot ws" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 5 Aug 2007 05:35:31 -0000
- Subject: [Bug c++/32993] New: Template type dedution of funtion reference includes default args
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
I have tested this code on "gcc version 4.3.0 20070202 (experimental)" as well
as "gcc version 3.4.4 (cygming special)".
f1, f2, d1 and d2 declare functions with the same types but one has default
parameters.
It appears that the standard requires that all default args should not
propagate to the type deduction at all. This is the behaviour in VC++ 2005 and
Comeau.
int f1( int p = 5 );
int f2( int p );
double d1( double p );
double d2( double p = 1.1 );
template <typename T>
T F( T fp )
{
return fp;
}
#include <iostream>
int main()
{
std::cout << F( f1 )() << "\n"; // uses default arg
std::cout << F( f2 )() << "\n"; // uses default arg of f1
std::cout << F( d1 )() << "\n"; // d1 has no default arg - error
std::cout << F( d2 )() << "\n"; // d2 has default arg but bot used here
}
--
Summary: Template type dedution of funtion reference includes
default args
Product: gcc
Version: 4.3.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: gianni at mariani dot ws
GCC build triplet: x86_64-redhat-linux
GCC host triplet: x86_64-redhat-linux
GCC target triplet: x86_64-redhat-linux
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32993