From Bugzilla Helper: User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.5) Gecko/20031016 Galeon/1.3.11a Description of problem: The following code is incorrectly compiled by gcc 3.2.2-5 when using options "-march=pentium4 -O2 -ffast-math -mfpmath=sse": === CUT HERE === const double max_loss = 1e7; double get_basic_path_loss(double a) { return 1.0; } double get_path_loss(void) { double loss; loss = get_basic_path_loss(1.0); return (loss < max_loss) ? loss : max_loss; } int main(void) { return get_path_loss() < 1e7 ? 0 : 1; } === CUT HERE === get_path_loss() should return 1.0, therefore main() should return 0, but actually 1 is returned. The generated assembly for get_path_loss() is get_path_loss: pushl %ebp movl %esp, %ebp subl $24, %esp movl $0, (%esp) movl $1072693248, 4(%esp) call get_basic_path_loss fstpl -8(%ebp) fldl .LC2 fldl -8(%ebp) fcomi %st(0), %st fcmovbe %st(1), %st fstp %st(1) movl %ebp, %esp popl %ebp ret The "fcomi" instruction seems to be wrong. Stock gcc-3.4-cvs seems to be fine. I have not tried other versions. I will upgrade if I have to, but I hope someone will make sure that the bug is really fixed. Version-Release number of selected component (if applicable): gcc-3.2.2-5 How reproducible: Always Steps to Reproduce: 1. Saved the sample program above as test.c. 2. Compile it as follows: gcc -o test -march=pentium4 -O2 -ffast-math -mfpmath=sse test.c 3. Run it: ./test ; echo $? Actual Results: 1 (which is the exit code from ./test) Expected Results: 0 Additional info:
This testcase works in 3.3.3-7 (current rawhide compiler).