Article View: net.bugs.v7
Article #65overflow in C re-revisited
From: utzoohenry
Date: Wed, 05 May 1982 19:30
Date: Wed, 05 May 1982 19:30
18 lines
1193 bytes
1193 bytes
Mhtsa!rick has missed my point. His quote from Kernighan+Ritchie, page 185, "The handling of overflow... is machine-dependent." is correct, but he should have read the next sentence: "All existing implementations of C ignore integer overflows...". The way 99% of all programmers interpret that second sentence is "nothing special happens when an overflow occurs". Wrong, as you can easily discover if you play with it. What the sentence really should say is "All existing implementations of C ignore THE POSSIBILITY OF integer overflows...". This makes it clear that anything can happen because the compiler simply doesn't care. DMR and I have corresponded about this in the past and newer manuals will presumably have revised wording. As an aside, it would be nice if the compiler could spot overflows in compile-time arithmetic and complain about them. The arguments against run-time checking don't apply there. I realize this is probably hard to retrofit into existing compilers, though.
Technical Details
Message-ID:
<anews.Autzoo.1637>Path:
arc1-ca.pugleaf.net!utzoo!henryShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!henry From: utzoo!henry Newsgroups: net.bugs.v7 Subject: overflow in C re-revisited Date: Wed, 05 May 1982 19:30:46 +0000 Message-ID: <anews.Autzoo.1637>