Created attachment 29704 [details] g++ -v output For background see http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36996 When compiled with -Os, the program below does not terminate. Here is my opinion: `mask` becomes undefined and it cause an unrelated variable `maskI' to become undefined. If that is a valid compilation of the program, it would make it very hard for programmers to reason about correctness. #include <stdio.h> int main () { int mask = 0, maskI; for (maskI = 0; maskI < 4; maskI++) { printf ("y %d\n", mask); mask += 0x55555555; } return 0; }
A program that depends on undefined behaviour cannot be correct.
dup *** This bug has been marked as a duplicate of bug 36996 ***