Dato che hai creato un nuovo thread sulla stessa questione (perché? ) qui chiudo.
Amaro C++, il gusto pieno dell'undefined behavior.
Regole del Forum