In what way(s), if any, does the C++ standard limit the effect of undefined behavior? For instance, in the code below, from the first if
inspecting undefined
is control flow constrained to follow either the then path or the else path? Is it allowed to skip both paths? Execute both paths (potentially in parallel)? Take a wild jump into the middle of the second if
?
void f(int undefined) {
bool startNuclearWar = true;
if (undefined > 0) {
printf("True path\n");
startNuclearWar = false;
} else {
printf("False path\n");
startNuclearWar = false;
}
if (startNuclearWar) {
lauchMissles();
}
}
Aucun commentaire:
Enregistrer un commentaire