Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail From: Eric Sosman Newsgroups: comp.lang.java.programmer,comp.lang.c Subject: Re: Arithmetic overflow checking Date: Tue, 12 Jul 2011 21:53:40 -0400 Organization: A noiseless patient Spider Lines: 34 Message-ID: References: <015aeb15-57db-48ab-9cd4-77f8448b632f@w24g2000yqw.googlegroups.com> <2rydnez7l-H5BYnTnZ2dnUVZ_vGdnZ2d@earthlink.com> <9LWdnZH2hdfmyYvTnZ2dnUVZ_vidnZ2d@posted.palinacquisition> <3797038f-22d1-40b2-8c12-60db5a0976b8@t5g2000yqj.googlegroups.com> <289ad570-65fc-49d8-9cc8-1f15d13ff3e3@gv8g2000vbb.googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Wed, 13 Jul 2011 01:54:20 +0000 (UTC) Injection-Info: mx04.eternal-september.org; posting-host="BrOwaJANne849xlH+KPYjQ"; logging-data="25745"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19kDezT3Y1ucrODdC/CSABG" User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.18) Gecko/20110616 Thunderbird/3.1.11 In-Reply-To: Cancel-Lock: sha1:HPAa0KQIiFBaS+BbQj/X0IVy7ZU= Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:6144 comp.lang.c:8219 On 7/12/2011 12:26 PM, markspace wrote: > On 7/12/2011 6:16 AM, Stefan Ram wrote: >> "BartC" writes: >>> a+b overflows, but then what? >> >> This can only be answered given the requirements >> specification of a specific project. > > > What I think he's saying is there's no way physically detect the > overflow in a language like C which has no exceptions. C has something far more flexible than exceptions: It has "undefined behavior." :-) This thread is dragging on in both comp.lang.java.programmer, where it began, and in comp.lang.c, to which some doubtless well- meaning but insufficiently wise person cross-posted it. The two languages are rather different (in Java, there *is* no integer overflow in C's sense), and the thread has become at least half- irrelevant to at least one of the two groups. Permit me to suggest that people who wish to discuss integer overflow in C should delete "comp.lang.java.programmer" from their replies, and likewise people who wish to discuss an alternate Java that handles overflow differently should delete "comp.lang.c". In this as in many other matters, the two languages have very little to do with each other. -- Eric Sosman esosman@ieee-dot-org.invalid