Bug 9027 – Getting address of overloaded function using `cast` selects the lexically first one if there is no match

Status
NEW
Severity
major
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2012-11-15T00:43:12Z
Last change time
2024-12-13T18:02:51Z
Keywords
accepts-invalid, pull, wrong-code
Assigned to
No Owner
Creator
Denis Shelomovskii
Moved to GitHub: dmd#18493 →

Comments

Comment #0 by verylonglogin.reg — 2012-11-15T00:43:12Z
--- void f1() { } void f1(int) { } extern(C) void f1(int) { } void f2() { } extern(C) void f2(int) { } extern(C) void f3(int) { } void f3() { } extern(Windows) void f4(long) { } extern(C) void f4(long) { } void main() { // ok, `void f1(int)` selected static assert( __traits(compiles, cast(void function(int)) &f1)); // fails, `void f2()` selected static assert(!__traits(compiles, cast(void function(int)) &f2)); // fails, `extern(C) void f3(int)` selected static assert(!__traits(compiles, cast(void function(int)) &f3)); // fails, `extern(Windows) void f4(long) { }` selected static assert(!__traits(compiles, cast(void function()) &f4)); } --- Probably related to Issue 7549 but this issue is fatal as it leads to all kinds of stack and memory corruption.
Comment #1 by github-bugzilla — 2012-11-15T06:59:16Z
Commit pushed to master at https://github.com/D-Programming-Language/druntime https://github.com/D-Programming-Language/druntime/commit/febee4fceb4e3c35920c6ec1841646b817e012bb Fix ambiguous `main` address selection. Such ambiguous `main` address selection compiles only because of Issue 9027 and works correctly by pure accident. * Issue 9027 URL: http://d.puremagic.com/issues/show_bug.cgi?id=9027 * Causing commit from pull #339: 278968f5029f0cc9137a0d21c641d64604674be2.
Comment #2 by k.hara.pg — 2014-04-16T07:35:45Z
Comment #3 by robert.schadek — 2024-12-13T18:02:51Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/18493 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB