Thread overview
[Issue 617] New: IFTI doesn't use normal promotion rules for non-template parameters
Nov 28, 2006
d-bugmail
Nov 29, 2006
Thomas Kuehne
Nov 30, 2006
d-bugmail
Apr 27, 2007
d-bugmail
Jan 22, 2008
d-bugmail
Jul 10, 2008
d-bugmail
November 28, 2006
http://d.puremagic.com/issues/show_bug.cgi?id=617

           Summary: IFTI doesn't use normal promotion rules for non-template
                    parameters
           Product: D
           Version: 0.175
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla@digitalmars.com
        ReportedBy: wbaxter@gmail.com


For regular function matching, an int argument can be automatically converted to a size_t.  But if IFTI is in play, then the difference between int and size_t in the function's parameter list causes IFTI to fail to find a match.

-------
import std.stdio : writefln;

void simple_func(char[] s, size_t i)
{
    writefln(s, i);
}
void simple_func_t(T)(T s, size_t i)
{
    writefln(s, i);
}


void main(char[][] args)
{
    // ok as basic function
    simple_func(args[0], 3);

    // ok with explicit type
    simple_func_t!(char[])(args[0], 3);

    // ok with exact match on non-template param
    simple_func_t!(char[])(args[0], 3u);

    // Fails to to match with IFTI:
    // "template template_deduction.simple_func_t(T) does not
    //    match any template declaration
    //  template template_deduction.simple_func_t(T) cannot
    //     deduce template function from argument types (char[],int)"
    simple_func_t(args[0], 3);
}


-- 

November 29, 2006
d-bugmail@puremagic.com schrieb am 2006-11-28:
> http://d.puremagic.com/issues/show_bug.cgi?id=617

> For regular function matching, an int argument can be automatically converted to a size_t.  But if IFTI is in play, then the difference between int and size_t in the function's parameter list causes IFTI to fail to find a match.
>
> -------
> import std.stdio : writefln;
>
> void simple_func(char[] s, size_t i)
> {
>     writefln(s, i);
> }
> void simple_func_t(T)(T s, size_t i)
> {
>     writefln(s, i);
> }
>
>
> void main(char[][] args)
> {
>     // ok as basic function
>     simple_func(args[0], 3);
>
>     // ok with explicit type
>     simple_func_t!(char[])(args[0], 3);
>
>     // ok with exact match on non-template param
>     simple_func_t!(char[])(args[0], 3u);
>
>     // Fails to to match with IFTI:
>     // "template template_deduction.simple_func_t(T) does not
>     //    match any template declaration
>     //  template template_deduction.simple_func_t(T) cannot
>     //     deduce template function from argument types (char[],int)"
>     simple_func_t(args[0], 3);
> }

Added to DStress as http://dstress.kuehne.cn/run/t/template_49_A.d http://dstress.kuehne.cn/run/t/template_49_B.d http://dstress.kuehne.cn/run/t/template_49_C.d

Thomas


November 30, 2006
http://d.puremagic.com/issues/show_bug.cgi?id=617





------- Comment #2 from wbaxter@gmail.com  2006-11-29 18:28 -------
(In reply to comment #1)
> >     // ok with exact match on non-template param
> >     simple_func_t!(char[])(args[0], 3u);

> Added to DStress as http://dstress.kuehne.cn/run/t/template_49_A.d http://dstress.kuehne.cn/run/t/template_49_B.d http://dstress.kuehne.cn/run/t/template_49_C.d
> 

Oops the line above is supposed to be *without* the explicit template arg:

     // ok with exact match on non-template param
     simple_func_t(args[0], 3u);

But it doesn't look like that will affect your dstress tests.


-- 

April 27, 2007
http://d.puremagic.com/issues/show_bug.cgi?id=617


thomas-dloop@kuehne.cn changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |leo.dahlmann@gmail.com




------- Comment #3 from thomas-dloop@kuehne.cn  2007-04-27 12:35 -------
*** Bug 1178 has been marked as a duplicate of this bug. ***


-- 

January 22, 2008
http://d.puremagic.com/issues/show_bug.cgi?id=617


larsivar@igesund.net changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |larsivar@igesund.net




------- Comment #4 from larsivar@igesund.net  2008-01-22 16:47 -------
Just noting that this bug (when propagated to GDC), means that code that should be portable to 64 bit targets isn't, and requires casts as a workaround.

Examples include

foo(cast(size_t)3)

instead of

foo(3u).


-- 

July 10, 2008
http://d.puremagic.com/issues/show_bug.cgi?id=617


bugzilla@digitalmars.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED




------- Comment #5 from bugzilla@digitalmars.com  2008-07-09 22:37 -------
Fixed dmd 1.032 and 2.016


--