I have a code that when compiled with --fast-math
I get, after running it (successfully):
Note: The following floating-point exceptions are signalling: IEEE_INVALID_FLAG IEEE_DIVIDE_BY_ZERO
Does anyone has any tip on how to debug that, given that the program does not throw any error? I can make the program break somewhere by adding the following compiler flags:
-ffpe-trap=zero,overflow,underflow
but the lines to where the error points do not make much sense (for instance in a line with an operation like x = (1 - y)**2
, and y
arrives to the line well defined. Worst, the error line changes sometimes even when I write a write(*,*) x, y
to check the value of the variables before the error (the error then occurs somewhere else).
Update: If i use only --fast-math -ffpe-trap=zero
then the error occurs, apparently, in a system library:
Program received signal SIGFPE: Floating-point exception - erroneous arithmetic operation.
Backtrace for this error:
#0 0x7f5321d81ad0 in ???
#1 0x7f5321d80c35 in ???
#2 0x7f5321a9151f in ???
at ./signal/../sysdeps/unix/sysv/linux/x86_64/libc_sigaction.c:0
#3 0x5564a17b1886 in ???
#4 0x5564a17b9083 in ???
#5 0x5564a17b9ca1 in ???
#6 0x5564a17eabbe in ???
#7 0x5564a17bbf7e in ???
#8 0x5564a17e71d0 in ???
#9 0x5564a179f318 in ???
#10 0x7f5321a78d8f in __libc_start_call_main
at ../sysdeps/nptl/libc_start_call_main.h:58
#11 0x7f5321a78e3f in __libc_start_main_impl
at ../csu/libc-start.c:392
#12 0x5564a179f364 in ???
#13 0xffffffffffffffff in ???
Floating point exception (core dumped)