www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 9027] New: Getting address of overloaded function using `cast` selects the lexically first one if there is no match

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9027

           Summary: Getting address of overloaded function using `cast`
                    selects the lexically first one if there is no match
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Keywords: accepts-invalid, wrong-code
          Severity: major
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: verylonglogin.reg gmail.com



11:43:12 MSK ---
---
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.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Nov 15 2012
parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9027




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


-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Nov 15 2012