What's the difference between?

delta trinity deltatrinity at hotmail.com
Mon Dec 6 15:03:53 CET 2004

>From: <nimzeros at naver.com>
>Reply-To: nimzeros at naver.com
>To: <gmp-discuss at swox.com>
>Subject: What's the difference between?
>Date: Sat, 4 Dec 2004 10:09:06 +0900 (KST)
>What's the difference between 
>mpz_set_str(p,"12423141325145251512521512343434343434",10) and
>mpz_set_str(p,1242314132514525151252151234343434343434,10) ?
>It is only difference of "". When I compiled with the second thing, 64bit 
>error happened , but when I used the first thing, there was no error.
>If I use mpz_set_str(p,"1242314132514525151252151234343434343434",10), is 

mpz_set_str second parameter is a pointer to a null terminated string.  If 
you pass a quoted string, the compiler will create a null-terminated string 
in the code/data space, and at runtime, the value passed is a pointer to 
that string.  If you specify unquoted string, the compiler will think that 
this is an explicit pointer value.  It will pass the number you specify 
(truncated to 32 bits in a 32 bits system) as the pointer value.  What is at 
that address is usually garbage.  Unexpected result may occur, and in a 
protected system, this is most likely to generate a protection fault 


More information about the gmp-discuss mailing list