Bug 412 – overloaded function resolution with null parameter

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D1 (retired)
Platform
x86
OS
Linux
Creation time
2006-10-09T06:54:00Z
Last change time
2014-02-15T13:19:41Z
Assigned to
bugzilla
Creator
benoit

Comments

Comment #0 by benoit — 2006-10-09T06:54:10Z
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)
Comment #1 by afb — 2006-10-09T06:57:41Z
Normally we use: alias char[] string; Name "String" implies a class, and typedef gives error below.
Comment #2 by benoit — 2006-10-09T07:36:23Z
(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.
Comment #3 by afb — 2006-10-09T08:00:34Z
Yeah, sorry. Does sound like a compiler bug. The error message given is bogus, at least...
Comment #4 by thomas-dloop — 2006-10-12T10:15:46Z
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 [email protected] 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-----
Comment #5 by bugzilla — 2006-10-18T13:26:02Z
Fixed DMD 0.170