4 ms·
In this particular case the code is wrong and can be fixed easily by swapping the assignment and the comparison. Likewise, code generators shouldn’t be generat
by Too 5y ago
In this particular case the code is wrong and can be fixed easily by swapping the assignment and the comparison.
Likewise, code generators shouldn’t be generating this faulty code.
Raising compiler error here is the only right thing to do.
There are of course more ambiguous examples, though obvious examples like the one above are sadly way too common.
- UncleMeat 5y agoWhy can't we say that the original code is wrong then? The whole point of having something be UB rather than implementation defined is because the language committee believes that it represents a bug in your program.