[Issue 18875] New: String literals can't disambiguate between const(char)[] and const(char)* overload.
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sat May 19 15:35:23 UTC 2018
https://issues.dlang.org/show_bug.cgi?id=18875
Issue ID: 18875
Summary: String literals can't disambiguate between
const(char)[] and const(char)* overload.
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Severity: normal
Priority: P1
Component: phobos
Assignee: nobody at puremagic.com
Reporter: dmitry.olsh at gmail.com
void add(const(char)* path){ }
void add(const(char)[] path){ }
void main(){
add("ABC");
}
On DMD 2.080 prints:
bug.d(6): Error: bug.add called with argument types (string) matches both:
bug.d(1): bug.add(const(char)* path)
and:
bug.d(3): bug.add(const(char)[] path)
I believe that for string literals we should probably pick D version of
const(char)[]. Some might argue the other way around since it's likely a
C-string function so it will be more efficient to present it as C-string.
Truth be told we need a sentinel terminated string type in DRuntime and cstring
would be one of them.
At the very least there has to be something in the spec about this.
--
More information about the Digitalmars-d-bugs
mailing list