home *** CD-ROM | disk | FTP | other *** search
/ minnie.tuhs.org / unixen.tar / unixen / PDP-11 / Bug_Fixes / Net.v7bugs / 0106 < prev    next >
Encoding:
Text File  |  1982-05-05  |  1.1 KB  |  24 lines

  1. Autzoo.1637
  2. net.bugs.v7
  3. utzoo!henry
  4. Wed May  5 19:30:46 1982
  5. overflow in C re-revisited
  6. Mhtsa!rick has missed my point.  His quote from Kernighan+Ritchie,
  7. page 185, "The handling of overflow... is machine-dependent." is
  8. correct, but he should have read the next sentence:  "All existing
  9. implementations of C ignore integer overflows...".  The way 99% of
  10. all programmers interpret that second sentence is "nothing special
  11. happens when an overflow occurs".  Wrong, as you can easily discover
  12. if you play with it.
  13.  
  14. What the sentence really should say is "All existing implementations
  15. of C ignore THE POSSIBILITY OF integer overflows...".  This makes it
  16. clear that anything can happen because the compiler simply doesn't
  17. care.  DMR and I have corresponded about this in the past and newer
  18. manuals will presumably have revised wording.
  19.  
  20. As an aside, it would be nice if the compiler could spot overflows
  21. in compile-time arithmetic and complain about them.  The arguments
  22. against run-time checking don't apply there.  I realize this is
  23. probably hard to retrofit into existing compilers, though.
  24.