Bug 9617 – ulong.max is wrongly accepted by smaller signed parameter
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-02-28T17:45:00Z
Last change time
2013-03-01T01:24:08Z
Keywords
accepts-invalid, pull
Assigned to
nobody
Creator
k.hara.pg
Comments
Comment #0 by k.hara.pg — 2013-02-28T17:45:44Z
This is wrong implicit conversion bug.
void main()
{
void f1(int) {}
void f2(short) {}
void f3(byte) {}
// Why these calls are accepted?
f1(ulong.max);
f2(ulong.max);
f3(ulong.max);
// But, if argument is not constant value, compilation fails.
ulong x;
//f1(x); // is not callable using argument types (ulong)
//f2(x); // is not callable using argument types (ulong)
//f3(x); // is not callable using argument types (ulong)
void f4(uint) {}
void f5(ushort) {}
void f6(ubyte) {}
// If parameter type is unsigned, it is collectly rejected
//f4(ulong.max); // is not callable using argument types (ulong)
//f5(ulong.max); // is not callable using argument types (ulong)
//f6(ulong.max); // is not callable using argument types (ulong)
}