mpz_array_init problems
David T. Ashley
dashley at abi-consulting.com
Tue May 31 03:22:37 CEST 2005
Addtionally, I'm not quite sure why the code he provided compiled without
warnings.
p is of type "pointer to mpz_t", which makes *p of type "mpz_t".
Of course, the joy of 'C' is that the compiler knows how to convert anything
to nearly anything else. (char *), (void *), (int *), (int)---they can all
be interchanged on all but the newer 64-bit machines.
'C' gives you enough rope to hang yourself, and will even do the favor of
throwing one end of the rope over the tree for you ...
-----Original Message-----
From: gmp-discuss-bounces at swox.com [mailto:gmp-discuss-bounces at swox.com]On
Behalf Of mrgrynch at comcast.net
Sent: Monday, May 30, 2005 9:07 PM
To: Demetri Stewart; gmp-discuss at swox.com
Subject: Re: mpz_array_init problems
It seems the problem here is you are trying to access memory you don't own.
When you define the array, you need to set aside the memory you need first,
before initializing it. Create the array as:
mpz_t p[<num_elements>]
mpz_array_init(p, <num_elements>, 500)
I hope this helps!
-Dave
-------------- Original message --------------
> I am using version 4.1.3 of GMP with version 3.2.3 of GCC.
>
> I need to create an array of multiprecision integers. mpz_array_init looks
> like it should produce the results I need; however, the code segment below
> bombs when it executes the mpz_array_init statement.
>
> int
> main()
> {
> mpz_t *p;
>
> mpz_arrray_init (*p, 10, 500);
>
> return (0);
> }
>
> Any suggestions? Anyone have work-around?
>
> Thanks.
>
> _________________________________________________________________
> Is your PC infected? Get a FREE online computer virus scan from McAfee.
> Security. http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963
>
> _______________________________________ ________
> gmp-discuss mailing list
> gmp-discuss at swox.com
> https://gmplib.org/mailman/listinfo/gmp-discuss
More information about the gmp-discuss
mailing list