James Kanze
12/17/2008 9:03:00 AM
On Dec 17, 5:03 am, red floyd <no.spam.h...@example.com> wrote:
> James Kanze wrote:
> > On Dec 16, 2:11 am, "Daniel T." <danie...@earthlink.net> wrote:
> >> Drawknob <Drawk...@gmail.com> wrote:
> >>> Changing the ordering of the resizes below gives me
> >>> different results-- if it's this way it works, if I swap
> >>> some lines, it results in corrupted data.
> > [...]
> >> I suggest the first thing you do is make sure *every*
> >> variable is initialized properly, replace every C array
> >> with a vector and use the 'at()' member function instead of
> >> the op[] member-function,
> > I agree with using vector, but why at()? In this case, the
> > immediate core dump you get with op[] would seem preferable.
> > (I know, the standard says it's undefined behavior, but any
> > decent implementation of std::vector will give you a core
> > dump---the ones with VC++ and g++ do, at any rate.)
> You won't necessarily get an immediate core dump if the
> capacity is larger than the size.
It's not guaranteed by the standard, ever. (It's undefined
behavior.) But you'll get the core dump immediately will with
any good implementation. You definitely do with g++ and VC++
(at least when you compile with the usual options---you can turn
it off with both).
--
James Kanze (GABI Software) email:james.kanze@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34