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





------- 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.


-- 
Oct 09 2006
prev sibling next sibling parent d-bugmail puremagic.com writes:
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. --
Oct 09 2006
prev sibling next sibling parent d-bugmail puremagic.com writes:
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...


-- 
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




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


-- 
Oct 18 2006