Illustration of the effect of register allocation on floating-point numbers rounding depending on internal precision as described in "The pitfalls of verifying floating-point computations" by David Monniaux, section 3.1.1.
$ cat dummy.c void do_nothing(double *x __attribute ((unused))) {} $ cat x87.c #include <assert.h> void do_nothing(double *x); int main(void) { double x = 0x1p-1022, y = 0x1p100, z; do_nothing(&y); z = x/y; if (z != 0) { do_nothing(&z); assert(z != 0); } return 0; } $ cc -std=c99 -Wall -W -pedantic -mfpmath=387 -O1 -o x87 dummy.c x87.c $ ./x87 x87: x87.c:12: main: Assertion `z != 0' failed. Aborted $ cc -std=c99 -Wall -W -pedantic -mfpmath=sse -O1 -o x87 dummy.c x87.c ./x87 $Example of how this behaviour affects real applications can be observed in PHP bug 53632.
![]() | Name | Last modified | Size | Description |
---|---|---|---|---|
![]() | Parent Directory | - | ||
![]() | HEADER.html | 2011-02-01 12:31 | 1.0K | |
![]() | x87.c | 2011-01-13 19:49 | 200 | |
![]() | Makefile | 2011-01-13 19:54 | 105 | |
![]() | dummy.c | 2011-01-13 20:01 | 53 | |