http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46080
--- Comment #3 from Uros Bizjak <ubizjak at gmail dot com> 2010-10-20 08:28:57 UTC --- (In reply to comment #2) > Created attachment 22089 [details] > sh script to test sqrtf > > Similar problems can also be found with: > > printf ("%.60f\n%.60f\n%.60f\n", sqrtf(x), sqrtf(x), sqrtf(x)); > > I've found that every GCC version I could test was showing some incorrect > behavior (but GCC 4.2.4 was the most consistent one). With the attached > script, > I get: > > -DSEP -O0 -O1 -O2 > GCC 3.4.6 SSS SSS SDD SDD > GCC 4.1.3 SSS SSS DSS DDS > GCC 4.2.4 SSS SSS DDD DDD (x86) > GCC 4.3.5 SSS SSS DSS DDD (ditto with GCC 4.3.2 on x86) > GCC 4.4.5 DSS SSD DSS DDD > > where S means that one gets the result in single precision (as expected) and D > means that one gets the result in double precision. You should use -ffloat-store to remove excess precision.