(Ref: http://lists.gnu.org/archive/html/gdb/2009-12/msg00004.html)
gdb
is missing the debug information of the cos
function, and therefore assume it is an int cos(...)
function, so the values are not returned correctly (esp. on x86 as the registers to store floating point return and integer return are different).
This could be worked around by specifying the type:
(gdb) p ((double(*)(double))cos) (1.0)
$18 = 0.54030230586813977