[Issue 22240] New: Erroneous overload selection bool vs long

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Aug 25 15:26:03 UTC 2021


https://issues.dlang.org/show_bug.cgi?id=22240

          Issue ID: 22240
           Summary: Erroneous overload selection bool vs long
           Product: D
           Version: D2
          Hardware: x86
                OS: Windows
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: deadalnix at gmail.com

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.

--


More information about the Digitalmars-d-bugs mailing list