3 ms·
Clearly, you don't! Once the program has undefined behavior, the compiler is free to optimize it out, so there just is no code left to debug at all! The dange
by informatimago 12y ago
Clearly, you don't!
Once the program has undefined behavior, the compiler is free to optimize it out, so there just is no code left to debug at all!
The danger, is to try to debug what's left. Since you start from wrong premisses, your debugging is bound to be wrong.
You should first define the behavior you want from your program (specifications).
Then write a program with defined behavior.
Then check whether the behavior implemented matches the behavior specified. If it doesn't then you have a bug to debug.
If you don't have a specification, you cannot have bugs: anything the program does, is as good as anything else, without specifications!