https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108989
Bug ID: 108989 Summary: Two small almost identical programs give different results Product: gcc Version: og10 (devel/omp/gcc-10) Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: d.j.allerton at sheffield dot ac.uk Target Milestone: --- Created attachment 54570 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=54570&action=edit A small program doing 2D geometry. No math calls, just addition, subtraction, mutiplication and division of floats. In a small program, the following lines give different reults: x = x0 + ((r1 * r1 - r2 * r2 + x2 * x2) / (2.0 * x2)); y = y0 + ((r1 * r1 - r3 * r3 + x3 * x3 + y3 * y3 - 2.0 * x3 * x) / (2.0 * y3)); printf("x=%f y=%f\n", x, y); and x = ((r1 * r1 - r2 * r2 + x2 * x2) / (2.0 * x2)); y = ((r1 * r1 - r3 * r3 + x3 * x3 + y3 * y3 - 2.0 * x3 * x) / (2.0 * y3)); printf("x=%f y=%f\n", x + x0, y + y0); the first example gives: x=-0.000000 y=33.070801 (which is wrong) the second example gives: x=0.000000 y=7.315198 (which is correct) The only difference is the addition of x0 and y0 in the sets of expressions. The two programs are attached. They don't use any libraries other than stdlib.h and stdio.h. I use gcc version 10.2.0 on msys2 on a PC and version 10.2.1 on a Raspberry Pi 4B and get the same errors with both compilers. A colleague gets the same errors with version 12.1.0 on a PC.