mpz_init(x) does not set x's value to zero
Christina Vichou
christin_vichou at hotmail.gr
Thu Feb 2 18:46:37 CET 2012
• The GMP version number, and if pre-packaged or patched then say so.
• A test program that makes it possible for us to reproduce the bug. Include instructions on
how to run the program.
• A description of what is wrong. If the results are incorrect, in what way. If you get a crash,
say so.
• If you get a crash, include a stack backtrace from the debugger if it’s informative (‘where’
in gdb, or ‘$C’ in adb).
• Please do not send core dumps, executables or straces.
• The configuration options you used when building GMP, if any.
• The name of the compiler and its version. For gcc, get the version with ‘gcc -v’, otherwise
perhaps ‘what ‘which cc‘’, or similar.
• The output from running ‘uname -a’.
• The output from running ‘./config.guess’, and from running ‘./configfsf.guess’
(might be the same).
• If the bug is related to ‘configure’, then the compressed contents of ‘config.log’.
• If the bug is related to an ‘asm’ file not assembling, then the contents of ‘config.m4’ and
the offending line or lines from the temporary ‘mpn/tmp-<file>.s’.
Hello,
I use fedora 14 and i have installed gnu mp 5.0.3 in my acer lap top.
There is a really unexpected problem. I simply try to compile the next lines:
source code:
------------------------------------------------------------------------------------------------
#include <stdio.h>
#include <gmp.h>
main(int argc, char **argv){
int a=5;
mpz_t kal, b;
mpz_init(kal);
mpz_init(b);
mpz_t *point=&kal;
printf("a=%d\n", a);
printf("*(&a)=%d\n", *(&a));
printf("*(&kal)=%d\n", *(&kal));
printf("&kal=%d\n", &kal);
printf("*point=%d\n", *point);
printf("&point=%d\n", &point);
printf("kal=%d\n", kal);
printf("b=%d\n", b);
mpz_clear(kal); mpz_clear(b);
return 0;
}
and the result in my system is every time something like:
----------------------------------------------------------------------------------------
a=5
*(&a)=5
*(&kal)=453871456
&kal=453871456
*point=453871456
&point=453871432
kal=453871456
b=453871440
As you san see i use *, & and an int type variable in order to find in which cases the initialization goes wrong. I can tell that the problem happens every time i want to initialize an mpz_t variable..
I really need help with this instantly.
Thank you very much.
More information about the gmp-bugs
mailing list