Compiler (gcc) option to abort on nan?

J

Joakim Hove

Hello,

am developing a floating point intensive program with gcc. At some
point in the calculations i get 'nan' ascribed to a variable, this is
*wrong* (i.e. a bug in my code), however the program happily continues
execution, propagating the nan around.

Since I know that the occurrence of a 'nan' is an error (in my code
anyway), I would like the program to just dump core at that point. Is
it possible to compile/link the program in a way which achieves this?


Best Regards

Joakim Hove
 
A

Anders Mikkelsen

Joakim said:
Hello,

am developing a floating point intensive program with gcc. At some
point in the calculations i get 'nan' ascribed to a variable, this is
*wrong* (i.e. a bug in my code), however the program happily continues
execution, propagating the nan around.

Since I know that the occurrence of a 'nan' is an error (in my code
anyway), I would like the program to just dump core at that point. Is
it possible to compile/link the program in a way which achieves this?


man assert


regards,
Anders
 
D

Dan Pop

am developing a floating point intensive program with gcc. At some
point in the calculations i get 'nan' ascribed to a variable, this is
*wrong* (i.e. a bug in my code), however the program happily continues
execution, propagating the nan around.

Since I know that the occurrence of a 'nan' is an error (in my code
anyway), I would like the program to just dump core at that point. Is
it possible to compile/link the program in a way which achieves this?

Ever considered grepping for "NaN" in the gcc man page?

Dan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,262
Messages
2,571,059
Members
48,769
Latest member
Clifft

Latest Threads

Top