[Issue 1603] String literals bind to pointer types

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Oct 21 10:33:32 PDT 2007


http://d.puremagic.com/issues/show_bug.cgi?id=1603


andrei at metalanguage.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Version|2.007                       |unspecified




------- Comment #4 from andrei at metalanguage.com  2007-10-21 12:33 -------
(In reply to comment #3)
> (In reply to comment #2)
> > Literal strings should not bind to const char *.
> 
> By my experiments, string literals are simultaneously of all of these types:
> 
> invariant(char)*
> invariant(wchar)*
> invariant(dchar)*
> invariant(char)[]
> invariant(wchar)[]
> invariant(dchar)[]
> 
> and therefore to the const versions of these types.  But there doesn't seem to
> be any documentation to the fact that they bind to the pointer types (unless I
> haven't found it).
> 
> So the issue has nothing to do with overload sets.

You are right. I suggest we leave this bug opened with the new title until a
formal resolution is found. Although accepting conversion of string literals to
invariant char* is sound, in my opinion that's a bit too friendly towards C
functions, and it creates unnecessary ambiguity. It's not too hard to add a
.ptr when calling a C function.

(I've set the version to unspecified.)


-- 



More information about the Digitalmars-d-bugs mailing list