# HG changeset patch # User thomask # Date 1175371894 0 # Node ID 724d76f90c83406e70a721c8ce38d1a2a02be09e # Parent b4b14259c7873a3e7ac8fd22a4947fe985a7c323 [Issue 1081] with using real and -O option, dmd generate bug code 2007-03-27 http://d.puremagic.com/issues/show_bug.cgi?id=1081 diff -r b4b14259c787 -r 724d76f90c83 run/o/odd_bug_14_A.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/run/o/odd_bug_14_A.d Sat Mar 31 20:11:34 2007 +0000 @@ -0,0 +1,55 @@ +// $HeadURL$ +// $Date$ +// $Author$ + +// @author@ +// @date@ 2007-03-27 +// @uri@ http://d.puremagic.com/issues/show_bug.cgi?id=1081 +// @desc@ [Issue 1081] with using real and -O option, dmd generate bug code + +module dstress.run.o.odd_bug_14_A; + +const real PI = 0x1.921fb54442d1846ap+1; + +extern(C) double sin(double); +extern(C) double round(double); + +int[] s_table; + +static this(){ + s_table = new int[2<<16]; + + real t = 0.0; + + for(int i=0; i< (2<<16); ++i){ + t += 1.0 / 65536.0; + s_table[i] = cast(int) round( 65536.0 * sin(PI*t) * sin(PI/2.0*t) / ((PI*PI/2.0)*t*t) ); + } + s_table[0] = 1<<16; +} + +int foo(int a) { + if((a <= -2<<16) || (a >= 2<<16)){ + return 0; + } + + if(a<0){ + a = -a; + } + + return s_table[a]; +} + +int main(){ + int d; + + for(int i = -0x1abcd; i < 0x20000; i += 0x10000){ + d += foo(i); + } + + if(0==d){ + assert(0); + } + + return 0; +} diff -r b4b14259c787 -r 724d76f90c83 run/o/odd_bug_14_B.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/run/o/odd_bug_14_B.d Sat Mar 31 20:11:34 2007 +0000 @@ -0,0 +1,55 @@ +// $HeadURL$ +// $Date$ +// $Author$ + +// @author@ +// @date@ 2007-03-27 +// @uri@ http://d.puremagic.com/issues/show_bug.cgi?id=1081 +// @desc@ [Issue 1081] with using real and -O option, dmd generate bug code + +module dstress.run.o.odd_bug_14_B; + +const real PI = 0x1.921fb54442d1846ap+1; + +extern(C) double sin(double); +extern(C) double round(double); + +int[] s_table; + +static this(){ + s_table = new int[2<<16]; + + double t = 0.0; + + for(int i=0; i< (2<<16); ++i){ + t += 1.0 / 65536.0; + s_table[i] = cast(int) round( 65536.0 * sin(PI*t) * sin(PI/2.0*t) / ((PI*PI/2.0)*t*t) ); + } + s_table[0] = 1<<16; +} + +int foo(int a) { + if((a <= -2<<16) || (a >= 2<<16)){ + return 0; + } + + if(a<0){ + a = -a; + } + + return s_table[a]; +} + +int main(){ + int d; + + for(int i = -0x1abcd; i < 0x20000; i += 0x10000){ + d += foo(i); + } + + if(0==d){ + assert(0); + } + + return 0; +} diff -r b4b14259c787 -r 724d76f90c83 run/o/odd_bug_14_C.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/run/o/odd_bug_14_C.d Sat Mar 31 20:11:34 2007 +0000 @@ -0,0 +1,55 @@ +// $HeadURL$ +// $Date$ +// $Author$ + +// @author@ +// @date@ 2007-03-27 +// @uri@ http://d.puremagic.com/issues/show_bug.cgi?id=1081 +// @desc@ [Issue 1081] with using real and -O option, dmd generate bug code + +module dstress.run.o.odd_bug_14_C; + +const real PI = 0x1.921fb54442d1846ap+1; + +extern(C) double sin(double); +extern(C) double round(double); + +int[] s_table; + +static this(){ + s_table = new int[2<<16]; + + float t = 0.0; + + for(int i=0; i< (2<<16); ++i){ + t += 1.0 / 65536.0; + s_table[i] = cast(int) round( 65536.0 * sin(PI*t) * sin(PI/2.0*t) / ((PI*PI/2.0)*t*t) ); + } + s_table[0] = 1<<16; +} + +int foo(int a) { + if((a <= -2<<16) || (a >= 2<<16)){ + return 0; + } + + if(a<0){ + a = -a; + } + + return s_table[a]; +} + +int main(){ + int d; + + for(int i = -0x1abcd; i < 0x20000; i += 0x10000){ + d += foo(i); + } + + if(0==d){ + assert(0); + } + + return 0; +}