Bug 22240 – Erroneous overload selection bool vs long

Status
RESOLVED
Resolution
DUPLICATE
Severity
enhancement
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86
OS
Windows
Creation time
2021-08-25T15:26:03Z
Last change time
2021-08-25T15:29:36Z
Assigned to
No Owner
Creator
deadalnix

Comments

Comment #0 by deadalnix — 2021-08-25T15:26:03Z
import std.stdio; void foo(bool b) { writeln("This is bool!"); } void foo(long l) { writeln("This is bool!"); } As expected by nobody, foo(0) and foo(1) actually call foo(bool). Every other integer value or a non constant integer value ends up calling foo(long). I assume that VRP detects that 0 and 1 can be coerced into bools, but even in this case, this should error with an error mentionning that overload resolutionf ailed as there are two candidates. There are 0 circumstance where the VRP call should be preferred to the non VRP one.
Comment #1 by snarwin+bugzilla — 2021-08-25T15:29:36Z
*** This issue has been marked as a duplicate of issue 9999 ***