[Issue 1650] New: Incorrect overload selected with IFTI
    d-bugmail at puremagic.com 
    d-bugmail at puremagic.com
       
    Thu Nov  8 16:53:52 PST 2007
    
    
  
http://d.puremagic.com/issues/show_bug.cgi?id=1650
           Summary: Incorrect overload selected with IFTI
           Product: D
           Version: 1.023
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla at digitalmars.com
        ReportedBy: sean at f4.ca
Given the following code:
    void proc(T)( T val )
    {
        printf( "proc:T\n" );
    }
    void proc(T,U=void)( T[] val )
    {
        printf( "proc:T[]\n" );
    }
    void main()
    {
        proc( 0 );
        proc( "abc".dup );
    }
I would expect to see:
    proc:T
    proc:T[]
Because proc:T[] is more specialized and thus should be preferred for the
second call.  Instead, it prints:
    proc:T
    proc:T
Interestingly, moving the dummy parameter to the first function:
    void proc(T,U=void)( T val )
    {
        printf( "proc:T\n" );
    }
    void proc(T)( T[] val )
    {
        printf( "proc:T[]\n" );
    }
    void main()
    {
        proc( 0 );
        proc( "abc".dup );
    }
Results in the expected behavior:
    proc:T
    proc:T[]
I can only assume this means that the dummy parameters required to support
overloading are considered for determining how specialized a particular
function is, even though they are not used in the function parameter list.
-- 
    
    
More information about the Digitalmars-d-bugs
mailing list