help-gplusplus
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Optimization breaks program


From: Paul Pluzhnikov
Subject: Re: Optimization breaks program
Date: 28 Apr 2004 16:17:05 -0700
User-agent: Gnus/5.0808 (Gnus v5.8.8) XEmacs/21.4 (Artificial Intelligence)

Paul Schneider <paulibaer@uboot.com> writes:

> >     Sometimes the declaration of large (or just not trivial sized)
> > arrays as 'automatic' (local off the stack).  Change these to 'static'
> > storage class (still local).
> >
> 
> 
> I'm getting a st9bad_alloc, so this might be worthwhile trying.

Getting 'std::bad_alloc' is almost guaranteed to be caused by either
heap corruption, or using uninitialized value while new()ing of
malloc()ing memory.

While allocating your arrays on the stack may make the bug hide,
it will not fix it.

Rebuild your program in debug mode and check it with valgrind,
you'll almost certainly find at least one bug in it.

Cheers,
-- 
In order to understand recursion you must first understand recursion.
Remove /-nsp/ for email.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]