Bug 17050 – Inconsistent overload resolution depending on member values of Rvalue struct objects

Status
NEW
Severity
normal
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2017-01-01T01:33:24Z
Last change time
2024-12-13T18:51:12Z
Assigned to
No Owner
Creator
Ali Cehreli
Moved to GitHub: dmd#19222 →

Comments

Comment #0 by acehreli — 2017-01-01T01:33:24Z
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
Comment #1 by acehreli — 2017-01-01T01:35:42Z
Comment #2 by robert.schadek — 2024-12-13T18:51:12Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/19222 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB