[lug] new operator in C++

D. Stimits stimits at idcomm.com
Sat Apr 27 19:34:19 MDT 2002


...
> DS> Had you done all the new operators in a row on separate variables,
> DS> your results would not have been the same in all likelihood. Or if
> DS> you had done other memory operations possibly the slot being used
> DS> would have been different.
> 
> weird, i am getting the same address each time.  something is
> overwriting it with a consistent value each time through the loop.
> actually, even in the first block (that's not a loop).
> 
> i wonder what's doing it?
> 
> and it does seem to do something more than just "put it on a free
> list", which is what i thought; if i try to do "*pi = 0" after the
> delete, i get a SEGV (even though pi itself has the same value as
> before the delete.)

The indirect memory being pointed to is no longer accessible after the
free. The pointer itself still exists, just not what it points at.

D. Stimits, stimits at idcomm.com



More information about the LUG mailing list