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