| ▲ | dgrunwald 3 days ago | |
The compiler cannot optimize that into `while(true)` because the original code does not encounter undefined behavior when `limit` is small enough to fit into `int`. What it can do: infer that `limit <= INT_MAX` and use that to optimize the code following after the loop (and in some cases, even the code before the loop). | ||
| ▲ | aka-rider 3 days ago | parent [-] | |
This isn't complete example. I don't remember the details unfortunately. But somehow compiler has decided that i <= limit is always true. | ||