On Sat, Dec 30, 2006 at 09:52:24PM -0800, Paul Eggert wrote:
> Wait, though: K&Rv2 is post-C89.  If memory serves, it was C89
> that established the rule that signed integer overflow has
> undefined behavior whereas unsigned overflow is well-defined.

I don't have the original K&R book so can't tell you for sure what it
said, but I wrote C in the early 80s.  unsigned was always defined to obey
the rules of arithmetic modulo 2**NBITS and I'm sure a statement to that
effect was included, because I remember being impressed and thankful; up
to then, I'd had great difficulty doing anything tricky with integers in
Fortran, which is what I'd been using up until then.  The behavior of
signed integral types on overflow was not specified, though I vaguely
recall some complaints that you couldn't build v7 Unix if your compiler
generated integer overflow traps.

Reply via email to