I checked if sqrt(-1.0) returns NaN (http://en.cppreference.com/w/c/numeric/math/sqrt). In gdb, it does not return NaN
(gdb) p/x sqrt(-1.0)
$10 = 0xe53a86a0
(gdb) p sqrt(-1.0)
$11 = -449149280
Does GDB call a different sqrt? I use gdb 7.6
I checked if sqrt(-1.0) returns NaN (http://en.cppreference.com/w/c/numeric/math/sqrt). In gdb, it does not return NaN
(gdb) p/x sqrt(-1.0)
$10 = 0xe53a86a0
(gdb) p sqrt(-1.0)
$11 = -449149280
Does GDB call a different sqrt? I use gdb 7.6
It looks like GDB does not have access to suitable debugging information. As a result, it assumes that sqrt
is a function which returns int
:
(gdb) ptype sqrt
type = int ()
You can use a cast to tell GDB the correct type:
(gdb) print ((double (*)(double))sqrt)(2)
$1 = 1.4142135623730951
Or you could load suitable debugging information.