[Issue 11900] New: Implicit cast of string literal -> char* causing ambiguous call
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Fri Jan 10 19:09:54 PST 2014
https://d.puremagic.com/issues/show_bug.cgi?id=11900
Summary: Implicit cast of string literal -> char* causing
ambiguous call
Product: D
Version: D2
Platform: All
OS/Version: All
Status: NEW
Severity: normal
Priority: P2
Component: DMD
AssignedTo: nobody at puremagic.com
ReportedBy: turkeyman at gmail.com
--- Comment #0 from Manu <turkeyman at gmail.com> 2014-01-10 19:09:45 PST ---
2 overloads exist:
void func(const(char)* str);
void func(const(char)[] str);
Called with literal string:
func("literal");
Complains; matches both, I don't think this is right...
Calles with a 'string':
string x = "not literal";
func(s);
Matches the array version, as expected.
I appreciate the convenience of the automatic string literal -> const(char)*
cast. But in this case, surely it should just choose the array version of the
function, like it does when calling with a 'string' variable?
The convenience should be just that, a convenience, not a hard rule...?
--
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list