News for hackers. Stuff that matters.
Re:Undefined behavior in C is a reading error by OskarS on Thursday May 20, 2021 @04:30PM (#27226793)
The loop counter is signed even if param is not, so i++ could overflow. fwrapv is a compiler flag, it is not part of the standard: it is a flag that mandates a certain behaviour in this case, but in standard C, the loop variable overflowing is definitely UB. No runtime guard needed, C compilers are just allowed to assume a fixed length. This is the whole reason signed overflow is UB in C, for exactly cases like this.

There are no comments on this comment yet.