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();
[...]
}
More From kr1zz
kr1zz Recommends
- Green Energy Investments Announced in Dubai (GreenEnergy)
- Nanotechnology Now On Solar Energy (GreenEnergy)


nnoia
19 febbraio 2008 at 10:38
gh! facile
kr1zz
19 febbraio 2008 at 11:09
mmm…per te
kr1zz
19 febbraio 2008 at 11:20
…ma ti dirò, la cosa pulp è che funzionava comunque!
nnoia
21 febbraio 2008 at 01:55
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