Skip navigation

Its weird to choke in dtor, but I had this situation where I was _inserting into a vector_, and getting a weird bug.

Naturally I start to think “must be a compiler bug..”

And you know when you get that thought, there’s something to be learned. So keep searching.

It turned out I was doing pushes of the form

vector<AABB> vec ;
vec.push_back( AABB( min, max ) ) ;

So the AABB was being

1. CONSTRUCTED with the AABB(min,max) ctor call
2. Copy constructed into the vector
3. destructed (item that was originally AABB(min,max) ctor created must be destroyed after copy into the vector)

So it was crashing on the dtor bit.

Turned out I had a non-initialized object ptr in AABB, and in ~AABB it was attempted to destroy that non-init ptr. Forgot to include init to 0 in AABB(min,max) ctor.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: