User account creation filtered due to spam.

Bug 32993 - Template type dedution of funtion reference includes default args
Summary: Template type dedution of funtion reference includes default args
Status: RESOLVED DUPLICATE of bug 4205
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.3.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
Depends on:
Reported: 2007-08-05 05:35 UTC by gianni
Modified: 2007-08-06 05:12 UTC (History)
7 users (show)

See Also:
Host: x86_64-redhat-linux
Target: x86_64-redhat-linux
Build: x86_64-redhat-linux
Known to work:
Known to fail:
Last reconfirmed:


Note You need to log in before you can comment on or make changes to this bug.
Description gianni 2007-08-05 05:35:30 UTC
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
Comment 1 Andrew Pinski 2007-08-06 05:12:30 UTC

*** This bug has been marked as a duplicate of 4205 ***