September 14, 2006 Incorrect code generation -O2 gdc | ||||
---|---|---|---|---|
| ||||
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> |
September 14, 2006 Re: Incorrect code generation -O2 gdc | ||||
---|---|---|---|---|
| ||||
Posted in reply to Johan Granberg Attachments: | Johan Granberg schrieb am 2006-09-14: > 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> Added to DStress as http://dstress.kuehne.cn/run/o/odd_bug_09_A.d http://dstress.kuehne.cn/run/o/odd_bug_09_B.d Thomas |
Copyright © 1999-2021 by the D Language Foundation