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) }
Comment #1 by k.hara.pg — 2013-02-28T18:16:25Z
Comment #2 by github-bugzilla — 2013-02-28T23:01:28Z
Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/d224d2c1103fbe220426a6c97772dc31f5af84ea fix Issue 9617 - ulong.max is wrongly accepted by smaller signed parameter https://github.com/D-Programming-Language/dmd/commit/4e6a467d59169740695c25a33936d8829f1c1cb0 Merge pull request #1704 from 9rnsr/fix9617 Issue 9617 - ulong.max is wrongly accepted by smaller signed parameter