digitalmars.D.bugs - [Issue 1603] New: Overload sets bug
- d-bugmail puremagic.com (26/26) Oct 20 2007 http://d.puremagic.com/issues/show_bug.cgi?id=1603
- d-bugmail puremagic.com (11/11) Oct 21 2007 http://d.puremagic.com/issues/show_bug.cgi?id=1603
- d-bugmail puremagic.com (10/10) Oct 21 2007 http://d.puremagic.com/issues/show_bug.cgi?id=1603
- d-bugmail puremagic.com (34/35) Oct 21 2007 http://d.puremagic.com/issues/show_bug.cgi?id=1603
- d-bugmail puremagic.com (14/31) Oct 21 2007 http://d.puremagic.com/issues/show_bug.cgi?id=1603
- d-bugmail puremagic.com (9/9) Mar 11 2009 http://d.puremagic.com/issues/show_bug.cgi?id=1603
http://d.puremagic.com/issues/show_bug.cgi?id=1603 Summary: Overload sets bug Product: D Version: 2.007 Platform: PC OS/Version: All Status: NEW Severity: normal Priority: P2 Component: DMD AssignedTo: bugzilla digitalmars.com ReportedBy: andrei metalanguage.com The following code does not compile: module A; extern(C) void foo(in char*) {} // end of module module B; void foo(string) {} // end of module import A, B; main() { foo("string"); } The call is ambiguous although it should make it to B.foo. --
Oct 20 2007
http://d.puremagic.com/issues/show_bug.cgi?id=1603 smjg iname.com changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |smjg iname.com Status|NEW |RESOLVED Resolution| |INVALID If it's ambiguous, it should error. This kind of hijacking is exactly why overload sets are defined the way they are. --
Oct 21 2007
http://d.puremagic.com/issues/show_bug.cgi?id=1603 andrei metalanguage.com changed: What |Removed |Added ---------------------------------------------------------------------------- Status|RESOLVED |REOPENED Resolution|INVALID | Literal strings should not bind to const char *. The overload sets corresponding to the two functions are disjoint. --
Oct 21 2007
http://d.puremagic.com/issues/show_bug.cgi?id=1603 smjg iname.com changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |spec Summary|Overload sets bug |String literals bind to | |pointer typesLiteral 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. Try this and see. ---------- extern(C) void foo(in char*) {} void main() { foo("string"); } invariant(char)* cp = "string"; invariant(wchar)* wp = "string"; invariant(dchar)* dp = "string"; invariant(char)[] ca = "string"; invariant(wchar)[] wa = "string"; invariant(dchar)[] da = "string"; ---------- And why is this issue set to version 2.007? That version isn't even out yet. --
Oct 21 2007
http://d.puremagic.com/issues/show_bug.cgi?id=1603 andrei metalanguage.com changed: What |Removed |Added ---------------------------------------------------------------------------- Version|2.007 |unspecifiedYou 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.) --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.
Oct 21 2007
http://d.puremagic.com/issues/show_bug.cgi?id=1603 bugzilla digitalmars.com changed: What |Removed |Added ---------------------------------------------------------------------------- Status|REOPENED |RESOLVED Resolution| |FIXED Fixed dmd 2.026 --
Mar 11 2009