Thread overview
[Issue 412] New: overloaded function resolution with null parameter
Oct 09, 2006
d-bugmail
Oct 09, 2006
d-bugmail
Oct 09, 2006
d-bugmail
Oct 09, 2006
d-bugmail
Oct 12, 2006
Thomas Kuehne
Oct 18, 2006
d-bugmail
October 09, 2006
http://d.puremagic.com/issues/show_bug.cgi?id=412

           Summary: overloaded function resolution with null parameter
           Product: D
           Version: 0.169
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla@digitalmars.com
        ReportedBy: benoit@tionex.de


typedef char[] String;

void f( char[] c,  char[] a ){
}

void f( char[] c, String a ){
}

void main(){
    f( "", "" );                // OK
    f( "", cast(String)"" );    // OK
    f( null, "" );              // OK
    f( null, cast(String)"" );  // line 14
}

// d.d(14): function d.f called with argument types:
//        (void*,String)
//matches both:
//        d.f(char[],char[])
//and:
//        d.f(char[],String)


-- 

October 09, 2006
http://d.puremagic.com/issues/show_bug.cgi?id=412





------- Comment #1 from afb@algonet.se  2006-10-09 06:57 -------
Normally we use:
alias char[] string;

Name "String" implies a class,
and typedef gives error below.


-- 

October 09, 2006
http://d.puremagic.com/issues/show_bug.cgi?id=412





------- Comment #2 from benoit@tionex.de  2006-10-09 07:36 -------
(In reply to comment #1)
> Normally we use:
> alias char[] string;
> 
> Name "String" implies a class,
> and typedef gives error below.
> 

This shouldn't be a example in good programming style. It should show a
compiler behaviour, that I think is a bug.
In this case I WANT a typedef to be able to have different function overloads
in both cases. That is "typedef" is for. That does not work with alias.
But now it doesn't work if the first parameter is null. I think the compiler
should be so smart, that he also can make the decision in this case.


-- 

October 09, 2006
http://d.puremagic.com/issues/show_bug.cgi?id=412





------- Comment #3 from afb@algonet.se  2006-10-09 08:00 -------
Yeah, sorry. Does sound like a compiler bug.
The error message given is bogus, at least...


-- 

October 12, 2006
d-bugmail@puremagic.com schrieb am 2006-10-09:
> http://d.puremagic.com/issues/show_bug.cgi?id=412

> typedef char[] String;
>
> void f( char[] c,  char[] a ){
> }
>
> void f( char[] c, String a ){
> }
>
> void main(){
>     f( "", "" );                // OK
>     f( "", cast(String)"" );    // OK
>     f( null, "" );              // OK
>     f( null, cast(String)"" );  // line 14
> }
>
> // d.d(14): function d.f called with argument types:
> //        (void*,String)
> //matches both:
> //        d.f(char[],char[])
> //and:
> //        d.f(char[],String)

Added to DStress as http://dstress.kuehne.cn/run/o/overload_27_A.d http://dstress.kuehne.cn/run/o/overload_27_B.d http://dstress.kuehne.cn/run/o/overload_27_C.d http://dstress.kuehne.cn/run/o/overload_27_D.d http://dstress.kuehne.cn/run/o/overload_27_E.d

Thomas


October 18, 2006
http://d.puremagic.com/issues/show_bug.cgi?id=412


bugzilla@digitalmars.com changed:

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




------- Comment #5 from bugzilla@digitalmars.com  2006-10-18 13:26 -------
Fixed DMD 0.170


--