This is GCC Bugzilla
This is GCC Bugzilla Version 2.20+
View Bug Activity | Format For Printing | Clone This Bug
The following trivial program fails with "-O1 -ffast-math" whereas it works without -ffast-math. This comes from ACATS. $ gnatmake -f -O1 -ffast-math c34003a gcc -c -O1 -ffast-math c34003a.adb gnatbind -x c34003a.ali gnatlink c34003a.ali -ffast-math $ ./c34003a raised PROGRAM_ERROR : c34003a.adb:5 explicit raise $ cat c34003a.adb PROCEDURE C34003A IS procedure Do_Fail is begin raise Program_Error; end Do_Fail; X : Float := 30.0; BEGIN IF 90.0 / X /= 3.0 THEN Do_Fail; END IF; END C34003A;
Simple C testcase: float x = 30.0; int main() { if ( 90.0/x != 3.0) abort(); return 0; } It works on PPC but not on i686 so this is a dup of bug 323 and invalid. *** This bug has been marked as a duplicate of 323 ***
Note what -ffast-math does is converts: 90.0/x into 1/x *90.0, so there is a precision loss which causes 1./0f/30.0 * 90.0 != 3.0. So this is still invalid.
Ok I see, but then it's not really a dup of 323 which has an incorrect program, here the program is correct and just broken when we allow unsafe math optimizations :) Laurent