[Issue 5827] New: Invalid implicit cast from "int function() ref" to "int function"

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Apr 10 01:13:50 PDT 2011


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

           Summary: Invalid implicit cast from "int function() ref" to
                    "int function"
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: timon.gehr at gmx.ch


--- Comment #0 from timon.gehr at gmx.ch 2011-04-10 01:10:06 PDT ---
The following invalid D code is accepted by DMD:

import std.stdio;

int a=0;
ref int g(){
    writeln("called g");
    return ++a;
}

void main(){
    int function() f=&g; //this should issue an error!
    writeln(cast(int)&a);
    writeln(f());
}

Output:
-144939256
called g
-144939256

(&g is implicitly cast to "int function() ref", after that, the identical
calling conventions for "ref int" (int*) and int result in an implicit
reinterpret-cast from "ref int" to int.)

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


More information about the Digitalmars-d-bugs mailing list