www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 412] New: overloaded function resolution with null parameter

reply d-bugmail puremagic.com writes:
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)


-- 
Oct 09 2006
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=412






Normally we use:
alias char[] string;

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


-- 
Oct 09 2006
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=412







 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. --
Oct 09 2006
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=412






Yeah, sorry. Does sound like a compiler bug.
The error message given is bogus, at least...


-- 
Oct 09 2006
prev sibling next sibling parent Thomas Kuehne <thomas-dloop kuehne.cn> writes:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

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 -----BEGIN PGP SIGNATURE----- iD8DBQFFLlsHLK5blCcjpWoRAkbiAKCiNJfmWx4owdJ3xlPFybasdbrZ3gCfZh2i s0HtNm8o/n+Ucw132sJ5GQ0= =RsTs -----END PGP SIGNATURE-----
Oct 12 2006
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=412


bugzilla digitalmars.com changed:

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





Fixed DMD 0.170


-- 
Oct 18 2006