Path: csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!weretis.net!feeder4.news.weretis.net!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail From: "MikeP" Newsgroups: comp.lang.java.programmer,comp.lang.c Subject: Re: Arithmetic overflow checking Date: Fri, 15 Jul 2011 21:27:46 -0500 Organization: A noiseless patient Spider Lines: 33 Message-ID: References: <9LWdnZH2hdfmyYvTnZ2dnUVZ_vidnZ2d@posted.palinacquisition> <3797038f-22d1-40b2-8c12-60db5a0976b8@t5g2000yqj.googlegroups.com> <289ad570-65fc-49d8-9cc8-1f15d13ff3e3@gv8g2000vbb.googlegroups.com> Injection-Date: Sat, 16 Jul 2011 02:27:38 +0000 (UTC) Injection-Info: mx04.eternal-september.org; posting-host="JFpB2gvi06BqMH/s1e1Gsw"; logging-data="8156"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18S2l9DfVRL6XD+SyJ/4sOk" X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.6109 X-RFC2646: Format=Flowed; Original X-Newsreader: Microsoft Outlook Express 6.00.2900.5931 Cancel-Lock: sha1:Zjcw7hMStUgVh3GyJOyB5AA89mY= X-Priority: 3 X-MSMail-Priority: Normal Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:6218 comp.lang.c:8332 Gene Wirchenko wrote: > On Thu, 14 Jul 2011 23:41:25 -0500, "MikeP" wrote: > >> BartC wrote: >>> "tm" wrote in message >>> news:289ad570-65fc-49d8-9cc8-1f15d13ff3e3@gv8g2000vbb.googlegroups.com... >>> >>>> And popular CPUs, which do detect integer overflow, do not >>>> trigger an interupt. This makes zero overhead overflow >>>> detection impossible. >>>> >>>> So software suffers because hardware / CPU designers want >>>> to save a transistor... >>> >>> Even if zero-overhead detection was possible, it's difficult to know >>> how to make use of this in C. For example: >>> >>> int a,b,c; >>> >>> c=a+b; >>> >>> The a+b overflows, but then what? >> >> Then you fix the bug in the program that causes the overflow. > > First, you have to detect the overflow. Since the language does > not make that easy, you may miss it. > To me, he seemingly implied that the overflow WOULD be detected after the addition in his example and that he was asking how to handle it.