Deprecate implicit `int` to `bool` conversion for integer literals
Walter Bright
newshound2 at digitalmars.com
Wed Nov 15 04:30:32 UTC 2017
On 11/14/2017 3:09 PM, H. S. Teoh wrote:
> I've been bitten before by things like this:
>
> void myfunc(char ch) { ... }
> void myfunc(int i) { ... }
>
> char c;
> int i;
>
> myfunc(c); // calls first overload
> myfunc('a'); // calls second overload (WAT)
> myfunc(i); // calls second overload
> myfunc(1); // calls second overload
I just tried:
import core.stdc.stdio;
void foo(char c) { printf("char\n"); }
void foo(int c) { printf("int\n"); }
void main() {
enum int e = 1;
foo(e);
foo(1);
foo('c');
}
and it prints:
int
int
char
I cannot reproduce your or Nick's error.
More information about the Digitalmars-d
mailing list