mpf_div changes value on a variable which doesn't participate in the division.

Zimmermann Paul Paul.Zimmermann at loria.fr
Sun Jan 8 11:40:55 CET 2012


       Hi,

I suggest you run valgrind on your program, it detects several problems:

[zimmerma at coing tmp]$ valgrind ./a.out 
...
==3034== Conditional jump or move depends on uninitialised value(s)
==3034==    at 0x35A641C7ED: sin (s_sin.c:104)
==3034==    by 0x400DB8: random_X_angle (in /tmp/a.out)
==3034==    by 0x4011E0: three_d_number_assign_random (in /tmp/a.out)
==3034==    by 0x4028D3: main (in /tmp/a.out)
...
==3034== Conditional jump or move depends on uninitialised value(s)
==3034==    at 0x35A7009E19: __gmpf_set_d (in /usr/lib64/gmp/core2-unknown-linu\
x-gnu/lib/libgmp.so.3.4.4)
==3034==    by 0x401952: three_d_bignum_assign_three_d_number (in /tmp/a.out)
==3034==    by 0x402902: main (in /tmp/a.out)
...
==3034== Conditional jump or move depends on uninitialised value(s)
==3034==    at 0x35A700B6C5: __gmpf_add (in /usr/lib64/gmp/core2-unknown-linux-\
gnu/lib/libgmp.so.3.4.4)
==3034==    by 0x40297F: main (in /tmp/a.out)
...
==2977== HEAP SUMMARY:
==2977==     in use at exit: 432 bytes in 3 blocks
==2977==   total heap usage: 18,132 allocs, 18,132 frees, 2,611,008 bytes allocated
==2977== 
==2977== LEAK SUMMARY:
==2977==    definitely lost: 432 bytes in 3 blocks
==2977==    indirectly lost: 0 bytes in 0 blocks
==2977==      possibly lost: 0 bytes in 0 blocks
==2977==    still reachable: 0 bytes in 0 blocks
==2977==         suppressed: 0 bytes in 0 blocks
==2977== Rerun with --leak-check=full to see details of leaked memory
==2977== 
==2977== For counts of detected and suppressed errors, rerun with: -v
==2977== Use --track-origins=yes to see where uninitialised values come from
==2977== ERROR SUMMARY: 3504 errors from 1000 contexts (suppressed: 6 from 6)

I suggest you first fix those problems.

Paul Zimmermann


More information about the gmp-bugs mailing list