[Issue 17050] New: Inconsistent overload resolution depending on member values of Rvalue struct objects

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Sat Dec 31 17:33:24 PST 2016


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

          Issue ID: 17050
           Summary: Inconsistent overload resolution depending on member
                    values of Rvalue struct objects
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: acehreli at yahoo.com

Because no member nor struct type is different below, all calls are expected to
be resolved to the same foo overload. However, that's not the case:

struct S {
    const(int)[] c;
}

int foo(S s) {
    return 1;
}

int foo(immutable(S) s) {
    return 2;
}

void main() {

    // This call is resolved to foo(S):
    const(int)[] arr;
    assert(foo(const(S)(arr)) == 1);

    // These are unexpectedly resolved to foo(immutable(S)):
    assert(foo(const(S)()) == 1);        // FAILS
    assert(foo(const(S)(null)) == 1);    // FAILS
}

Ali

--


More information about the Digitalmars-d-bugs mailing list