[Issue 3797] Regression(2.038): Implicit conversion between incompatible function pointers
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sat May 14 08:17:01 PDT 2011
http://d.puremagic.com/issues/show_bug.cgi?id=3797
timon.gehr at gmx.ch changed:
What |Removed |Added
----------------------------------------------------------------------------
Version|2.040 |D2
--- Comment #11 from timon.gehr at gmx.ch 2011-05-14 08:12:54 PDT ---
(In reply to comment #8)
> *** Issue 5827 has been marked as a duplicate of this issue. ***
Well, not exactly. But I guess it can be fixed together. My bug report was
about function pointers with _different return types_ converting to each other:
Timon Gehr wrote:
> 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