help-gplusplus
[Top][All Lists]
Advanced

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

Re: Mysterious support for dynamic arrays?


From: Paul Pluzhnikov
Subject: Re: Mysterious support for dynamic arrays?
Date: Thu, 26 Oct 2006 20:55:54 -0700
User-agent: Gnus/5.1006 (Gnus v5.10.6) XEmacs/21.4 (Jumbo Shrimp, linux)

ondrugs@gmail.com writes:

> On a whim I tested something the other day, which appears to work with
> g++ 3.3.4.

Yes, this works with other versions of gcc as well.

> Unfortunately it sometimes appears to exhibit flaky
> behavior when statically linking...

Static linking is bad for many reasons, and you shouldn't be doing
unless you really really know what you are doing.

But "random" crashes on the same machine on which the binary was
built is not one of these reasons.

> (i.e. mysterious segfault on the
> line following the declaration of the array).

To reproduce this, it would help to know exactly what OS you
are using, and exactly how you built this static exe.

If may also help to know for which values of "i" you observed
the crash.

If the OS is Linux, knowing whether exec-shield is on and
randomize_va_space are on may also give a clue.

> class Foo

This isn't a compilable test case. In the future, please post
*complete* tests.

> In the above program the function "test" will dynamically create an
> array "foo" with "i" elements,

[on stack]

> which gets freed automatically upon exit of the function.

It doesn't get "free"d, but goes out of scope (just like any other
local variable).

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]