开发者

Stopping the debugger when a NaN floating point number is produced

开发者 https://www.devze.com 2023-02-18 05:34 出处:网络
I have an C++ program. Somewhere in the program (hard to reproduce, but reproduceable) a caclculation res开发者_如何转开发ults in a float beeing set to a NaN. Since a floating point operation involvin

I have an C++ program. Somewhere in the program (hard to reproduce, but reproduceable) a caclculation res开发者_如何转开发ults in a float beeing set to a NaN. Since a floating point operation involving a NaN results in a NaN, this spreads fast.

Is there any way I can setup the compiler (gcc 4.4) or the debuger (gdb) to stop when a floating point operation results in a NaN? That would be extremely useful.

Thanks! Nathan

PS: It might matter: I am working under ubuntu linux 10.10.


You could enable floating point exceptions - see glibc Control Functions - then you'll get a SIGFPE when your NaN value is produced

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号