I had an annoying bug, where I forgot to write do in a do...while loop.
int main() {
/*do*/ {
int status = foo();
} while (status);
}
Why does this still compile and run? It seems to me that the compiler should reject this as nonsensical or at least raise a warning (I have -Wall
in my compiler options). I'm using C++11.
From what I could tell, the braced code runs { ... }
and then the programme checks the condition in the while clause ad infinitum.
Aucun commentaire:
Enregistrer un commentaire