[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug in mpz_init
From: |
Michael de Mare |
Subject: |
bug in mpz_init |
Date: |
Sun, 01 Jun 2003 16:51:22 -0400 |
User-agent: |
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.2.1) Gecko/20030225 |
I initialize three seperate variables separately:
mpz_init(X1);
mpz_init(X2);
mpz_init(J);
mpz_init(T);
after initialization, the variables all point to the same data:
4: T = {{_mp_alloc = 1, _mp_size = 0, _mp_d = 0x804b6d0}}
3: X2 = {{_mp_alloc = 1, _mp_size = 0, _mp_d = 0x804b6d0}}
2: X1 = {{_mp_alloc = 1, _mp_size = 0, _mp_d = 0x804b6d0}}
1: X0 = {{_mp_alloc = 1, _mp_size = -1, _mp_d = 0x804b6e0}}
so, when I change the value of X2, X1 and T get changed too:
mpz_set_ui(J, 1l);
member(X1, D, X0, J, S);
mpz_set(T, X1);
#ifdef DEBUG
fprintf(stderr, "\nX1=");
mpz_out_str(stderr, 10, X1);
fprintf(stderr,"\nT=");
mpz_out_str(stderr, 10, T);
fprintf(stderr,"\n");
#endif
mpz_set_ui(J, 2l);
member(X2, D, X0, J, S);
#ifdef DEBUG
fprintf(stderr, "\nX0=");
mpz_out_str(stderr, 10, X0);
fprintf(stderr, "\nX1=");
mpz_out_str(stderr, 10, X1);
fprintf(stderr,"\nT=");
mpz_out_str(stderr, 10, T);
fprintf(stderr, "\nX2=");
mpz_out_str(stderr, 10, X2);
fprintf(stderr, "\n");
#endif
X1=2
T=2
X0=-1
X1=4
T=4
X2=4
-Mike
- bug in mpz_init,
Michael de Mare <=