Why does gdb evaluate sqrt(3) to 0?

后端 未结 5 1340
眼角桃花
眼角桃花 2020-11-28 13:40

The square root of 3, as estimated by Wolfram Alpha:

1.7320508075688772935274463415058723669428052538103806280558...

When I do sqrt(3

5条回答
  •  盖世英雄少女心
    2020-11-28 14:23

    To call a function without debug info, you must explicitly tell gdb the type for the return and arguments, using a function pointer cast. So, for your example:

    (gdb) print ((double (*) (double)) sqrt) (3)
    $1 = 1.7320508075688772
    

提交回复
热议问题