I always thought the problem with this was that the compilers do loads of these optimisations in very mundane ways. Eg if I have a
#define FOO 17
void bar(int x, int y) {
if (x + y >= FOO) {
//do stuff
}
}
void baz(int x) {
bar(x, FOO);
}
the compiler can inline the call to bar in baz, and then optimise the condition to (x>=0)… because signed integer overflow is undefined, so can’t happen, so the two conditions are equivalent.
The countless messages about optimisations like that would swamp ones about real dangerous optimisations.
The countless messages about optimisations like that would swamp ones about real dangerous optimisations.