double-check your damn pointers, okay? – febbraio 13th, 2008

Yesterday, working on my thesis, I felt like I died and resurrected more than once in a few hours. Trust me, I’m beginning to understand the way the compiler feels ;-)

Jokes apart, the following C++ code contains a bug similar to the one I found: can you spot it? (please forgive the bad indent )

void calledMethod( some_class *object )
{
arg = doSomething();
delete object;
object = new some_class( arg );
}

void callerMethod()
{
[...]
calledMethod( anObject );
anObject.doSomethingElse();
[...]
}

Related posts:

  1. Unavailable Visual Studio Intellisense in C++ projetcs
  2. funziona?
  3. post simili

Tags: , , , , ,

4 Comments
Posted in geek, me

4 Responses to “double-check your damn pointers, okay?”

  1. nnoia scrive:

    gh! facile :-P

  2. nnoia scrive:

    funzionava comunque perchè lo usavi poco dopo e nel resto della app probabilmente hai una gestione locale della memoria, quindi la tua struttura era ancora lì, anche se pronta ad essere sovrascritta :-)

Leave a Reply

Leave a Reply

or chancel