3 ms·
Sounds like the compiler didn't correctly adhere to calling conventions without an explicit return statement. Wouldn't that even be a compiler bug allowing no
by ascar 5y ago
Sounds like the compiler didn't correctly adhere to calling conventions without an explicit return statement.
Wouldn't that even be a compiler bug allowing no return statements, but then incorrectly handling scope?
- tux3 5y agoIt's undefined behavior, the compiler can do whatever it wants. Here the compiler assumes the function never returns (because it would be UB since there's no return statement), so it looks like it just didn't bother to add a loop exit at all. This is standard compliant.
- nybble41 5y agoActually it's only undefined (per C99 anyway) if the return value is used: > If the } that terminates a function is reached, and the value of the function call is used by the caller, the behavior is undefined. So if the return value is never used then there is no undefined behavior and a standards-compliant compiler isn't allowed to optimize away the loop exit condition.