Memory issue

Craig Helfgott chelfgott at
Tue Dec 21 16:05:30 CET 2010

What does "VLA in C++ are a non-standard gcc extension." mean?

On Tue, Dec 21, 2010 at 4:30 AM, Marc Glisse <marc.glisse at> wrote:

> On Mon, 20 Dec 2010, Craig Helfgott wrote:
>  I ran with valgrind, using the flags suggested.  It claims there is no
>> memory error or memory leak, and that all the blocks are reachable.
>> However, it was also claiming several 100MB of memory in "reachable"
>> blocks
>> when I killed the run, and I know this isn't correct.  I've tracked the
>> problem down to probably being somewhere in my complex Gamma subroutine as
>> opposed to my real (or complex) exp subroutine.
>> I've basically defined
>> struct mpc_t {
>>      mpf_class re;
>>      mpf_class im;
>> }
>> and my mpc_gamma returns one of those, but most of the gamma computation
>> is
>> done with arrays of mpz_class variables (again a binary splitting
>> algorithm):
>> mpz_class NumerTermsRe[LgPrecisionForGam+3],
>>            NumerTermsIm[LgPrecisionForGam+3];
>> mpz_class DenomTermsRe[LgPrecisionForGam+3],
>>            DenomTermsIm[LgPrecisionForGam+3];
> VLA in C++ are a non-standard gcc extension.
>  My guess is that somehow my subroutine is not properly freeing these up
>> when
>> it finishes.  But I've tried delete and free and can't get my program to
>> compile properly with them.  Can anyone give me a clue as to how I can
>> ensure that the memory bound up in those arrays is freed up when my
>> subroutine exits?
> In gmpxx.h, make the mp*_class constructors and destructors print
> something.
> --
> Marc Glisse

More information about the gmp-discuss mailing list