Q:

Getting array boundary exception that is so weird

I'm trying to implement a space invader game, now I'm trying to check if bullets hit an invader, then I remove it.  
I'm ONLY get an exception when I try to shoot the last invader in the row.  
For e.g If I have just one row and 8 invaders, the last one, when the bullet hits it, I got a strange boundary out of exception.  
The initialization is like that, in pseudo code:
struct Invaders_t
{
    vector<Invader*> *invaders;
}
for (int j = 0; j < 1; j++)
    {
        x_spacing = 15;
        for (int i = 0; i < 8; i++)
        {
            Invader *invader = new Invader();
            g_Invaders.invaders->push_back(invader);

    } 

for each frame: 
for (int x = 0; x < 1; x++)
        {
            for (int y = 0; y < 8; y++)
            {
                Invader *pInvader = (*(g_Invaders.invaders))[x*8 + y];

                if (pInvader ! = nullptr && pInvader->AlienAtals->GetImage() ! = nullptr)
                {

                    for (list<Bullet*>::iterator it = ship->Bullets->begin(); it ! = ship->Bullets->end(); it++)
                    {
                        float left = (*it)->Position.x - 5;
                        float top = (*it)->Position.y - 13;

                        if (CheckCollision(left, top, pInvader->AlienSprite->m_X, pInvader->AlienSprite->GetImage()->GetWidth()/4
                            , pInvader->AlienSprite->m_Y, pInvader->AlienSprite->GetImage()->GetHeight()/4))
                        {
                            std::vector<Invader*>::iterator iter = g_Invaders.invaders->begin();
                            std::advance(iter, (x *8) + y);
                            Invader *invader = *iter;
                            g_Invaders.invaders->erase(iter);
                            delete invader;
                        }

                    }
                }
            }
        }

A:

When you delete an invader (g_Invaders.invaders->erase(iter);), the size of the vector decreases by 1 (all vector's elements after iter shift by 1 position to the beginning, filling the vacant space).  Your code doesn't expect this and continues iterating over the vector as if still had the full set of elements.