[Bug tree-optimization/88896] [8/9 Regression] integer overflow check optimized away
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88896 --- Comment #4 from Jakub Jelinek --- The compiler optimizes the program with the assumption that undefined behavior doesn't happen. So, e.g. it can remove loop condition if it proves that undefined behavior happens before the last iteration and many other possibilities. Use -fsanitize=undefined to discover the UB if unsure (though that doesn't catch e.g. aliasing bugs).
[Bug tree-optimization/88896] [8/9 Regression] integer overflow check optimized away
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88896 --- Comment #3 from Daniel Starke --- Never mind my question.
[Bug tree-optimization/88896] [8/9 Regression] integer overflow check optimized away
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88896 --- Comment #2 from Daniel Starke --- You are right. So you are saying that the compiler actually checks all cases of the loop?
[Bug tree-optimization/88896] [8/9 Regression] integer overflow check optimized away
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88896 Jakub Jelinek changed: What|Removed |Added Status|UNCONFIRMED |RESOLVED CC||jakub at gcc dot gnu.org Resolution|--- |INVALID --- Comment #1 from Jakub Jelinek --- Started with r251141, but it seems your testcase is invalid: test.c:72:101: runtime error: signed integer overflow: 35792640 * 60 cannot be represented in type 'int' Guess you want to e.g. change * 365 to * 365U or * (uint32_t) 365, so that all the arithmetics is done in uint32_t type when you want to support up to uint32_t max.