Pardon, ho letto male il tuo codice.
Amaro C++, il gusto pieno dell'undefined behavior.
Regole del Forum