See results below On Wed, Nov 10, 2010 at 6:34 AM, David Brennan <da...@brennanhome.com> wrote: > Thank you Paul, > > On Wed, Nov 10, 2010 at 12:08 AM, Paul D. DeRocco > <pdero...@ix.netcom.com> wrote: >>> From: David Brennan >>> >>> I am using a relatively recent CVS of eCos on an x86 VME >>> target. I am trying to get an existing application working, >>> and I stumbled across an unusual result. >>> >>> The code called floor() with a value of 0.048000000000000001. >>> the correct return value should have been 0.0. >>> >>> Single stepping through the "bit twiddling" looked like it >>> was pursuing the correct code path, but at this point, >>> somthing went wrong. >>> >>> 97 if(huge+x>0.0) {/* return 0*sign(x) if |x|<1 */ >>> (gdb) s >>> 98 if(i0>=0) {i0=i1=0;} >>> (gdb) p i0 >>> $4 = 8 >>> (gdb) s >>> 131 } >>> (gdb) info locals >>> i0 = 8 >>> j0 = -5 >>> i = 1067989024 >>> x = 0.048000000000000001 >>> (gdb) li >>> 126 } >>> 127 } >>> 128 CYG_LIBM_HI(x) = i0; >>> 129 CYG_LIBM_LO(x) = i1; >>> 130 return x; >>> 131 } >>> 132 >>> 133 #endif // ifdef CYGPKG_LIBM >>> 134 >>> 135 // EOF s_floor.c >>> >>> It appears that the code did not run line 98 correctly. >> >> <snip> >> >>> I am using a compiler that I built (so that is most likely >>> the problem). I am using OS X for my host, and there are not >>> pre-built binaries for that. >> >> I would think examining the assembly language would clear up the mystery, >> especially if you find the problem persists with optimization turned off. >> For instance, it could be that the arithmetic doesn't work because >> something's busted in the FP support, but the sign test works correctly >> because it doesn't use an FP instruction to test the sign. >> >> -- >> >> Ciao, Paul D. DeRocco >> Paul mailto:pdero...@ix.netcom.com >> > <snip> > > I will re-run the floor test later today without optimization. But if > that solves the problem, then what? Is this a gcc bug? Or a gcc > configuration error? > > Thanks again for your help > David Brennan >
Turning off optimization allows the floor test to pass. (gdb) c Continuing. INFO:<Starting tests from testcase /opt/ecos-old/eCosIRL/OS/ecos/packages/language/c/libm/current/tests/vectors/floor.c for Math library floor() function> INFO:<Still crunching, please wait...> INFO:<Still crunching, please wait...> INFO:<Still crunching, please wait...> INFO:<Still crunching, please wait...> INFO:<Still crunching, please wait...> INFO:<Still crunching, please wait...> INFO:<Still crunching, please wait...> INFO:<Still crunching, please wait...> INFO:<Still crunching, please wait...> INFO:<Still crunching, please wait...> INFO:<Still crunching, please wait...> PASS:<floor() is stable> EXIT:<Finished tests from testcase /opt/ecos-old/eCosIRL/OS/ecos/packages/language/c/libm/current/tests/vectors/floor.c for Math library floor() function> This will let me continue on my project. But I would like for optimization to work. What is the best method for approaching gcc maintainers about this issue? Thank you for your help David Brennan -- Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss