# Assertion b2Assert(m_bodyCount > 0) showing an error

I have the following code for deleting a Box2D body:

void b2World::DestroyBody(b2Body* b)
{
b2Assert(m_bodyCount > 0);
b2Assert(IsLocked() == false);
if (IsLocked())
{
return;
}

// Delete the attached joints.
b2JointEdge* je = b->m_jointList;
while (je)
{
b2JointEdge* je0 = je;
je = je->next;

if (m_destructionListener)
{
m_destructionListener->SayGoodbye(je0->joint);
}

DestroyJoint(je0->joint);

b->m_jointList = je;
}
b->m_jointList = NULL;

// Delete the attached contacts.
b2ContactEdge* ce = b->m_contactList;
while (ce)
{
b2ContactEdge* ce0 = ce;
ce = ce->next;
m_contactManager.Destroy(ce0->contact);
}
b->m_contactList = NULL;

// Delete the attached fixtures. This destroys broad-phase proxies.
b2Fixture* f = b->m_fixtureList;
while (f)
{
b2Fixture* f0 = f;
f = f->m_next;

if (m_destructionListener)
{
m_destructionListener->SayGoodbye(f0);
}

f0->Destroy(&m_blockAllocator);
f0->~b2Fixture();
m_blockAllocator.Free(f0, sizeof(b2Fixture));

b->m_fixtureList = f;
b->m_fixtureCount -= 1;
}
b->m_fixtureList = NULL;
b->m_fixtureCount = 0;

// Remove world body list.
if (b->m_prev)
{
b->m_prev->m_next = b->m_next;
}

if (b->m_next)
{
b->m_next->m_prev = b->m_prev;
}

if (b == m_bodyList)
{
m_bodyList = b->m_next;
}

--m_bodyCount;
b->~b2Body();
m_blockAllocator.Free(b, sizeof(b2Body));
}


When I close the game I get an exception, and the debugger points to the first line :

b2Assert(m_bodyCount>0);


What exactly does this mean?

An assertion failure happens when the expression returns 0, in this case when m_bodyCount is lower or equal to 0. This means that, whenever your code executes b2World::DestroyBody();, all the previously created b2Bodys are already destroyed, if there ever were any created in the first place.
If you did create at least one (1) b2Body* instance, make sure that that specific instance isn't deleted multiple times in the code (in multiple instances of your class A for example), since very weird bugs can occur because of that.