[Issue 11900] Implicit cast of string literal -> char* causing ambiguous call

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Jan 11 01:34:45 PST 2014


https://d.puremagic.com/issues/show_bug.cgi?id=11900



--- Comment #5 from Jakob Ovrum <jakobovrum at gmail.com> 2014-01-11 01:34:43 PST ---
(In reply to comment #4)
> (In reply to comment #3)
> > (In reply to comment #2)
> > > Well it's kinda like you say, this overload set is very common, if you have a C
> > > function, and you want to produce a D wrapper which receives a string and calls
> > > through using toStringz.
> > 
> > The ambiguity with string literal arguments probably means it's not overly
> > common at this stage, but regardless, its popularity does not justify its use.
> > We have no obligation to make concessions to enable bad code.
> 
> How is it a concession? It seems to me like the concession was already made to
> make interacting with C functions easier. I'd say if anything, this is a bug
> that stems from that decision.

It complicates overloading rules.

> There's nowhere else in D where a dynamic array can implicitly convert to a
> pointer... why does it happen ONLY in the case of a string literal?

String literals are not dynamic arrays of a particular type. They are
polysemous: they can be UTF-8, UTF-16 or UTF-32 strings; to wit, there is no
place in the language where implicit conversion happens between dynamic arrays
of different code unit element types, either.

-- 
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