Incorrect code generation -O2 gdc
Johan Granberg
lijat.meREM at OVEgmail.com
Thu Sep 14 00:27:23 PDT 2006
The following code generates an assert error when compiling with gdc and
-O2 on my iBook G3 800mhz OS X 10.4.7
gdc (GCC) 4.0.1 (gdc 0.19, using dmd 0.162)
Copyright (C) 2005 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
It looks like something goes wrong when copying structs (or I'm
incorrect in believing structs is just binary copied)
<code>
struct SigeCallback
{
union
{
void delegate(uint) del;
void function(uint) dfp;
}
static SigeCallback opCall(void function(uint) c,uint i)
{
SigeCallback a;
a.dfp=c;
return a;
}
}
SigeCallback f;
static this()
{
f=SigeCallback(&sigeFpNull,0);//this line causes an assert error
//f.dfp=&sigeFpNull;//this line works ok
}
void sigeFpNull(uint i){}
void main()
{
sigeFpNull(0);
assert(f.dfp);f.dfp(0);//line 26
}
/* output from running this
$ ./test
Error: AssertError Failure test.d(26)
*/
</code>
More information about the Digitalmars-d-bugs
mailing list