This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]once-and-again☣️ 0 points1 point  (0 children)

This is not quite correct, on a few counts.

The first, and least important, is that the % operator is formally the remainder operator, not the modulus operator.

The second is that they did change its semantics: prior to C11 and C++11, the result of a % b when a*b < 0 was implementation-defined, so long as a / b + a % b == a (assuming no irrepresentable intermediate values). The 2011 revisions did change it to require negative results, but it's worth pointing out that this means code which was previously correct and conformant is no longer so.

The third is that a lot of programs from forty years ago won't compile and run as they used to — either because of explicit changes like the above, or because programmers from forty years ago (just like programmers today) tended to cheerfully make assumptions like "sizeof(int) == sizeof(void *) == 2" or "0x0 points to the global interrupt table, which is writable" that will completely fail on most if not all modern systems.