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: markspace <-@.> Newsgroups: comp.lang.java.programmer,comp.lang.c Subject: Re: Arithmetic overflow checking Date: Tue, 12 Jul 2011 09:26:49 -0700 Organization: A noiseless patient Spider Lines: 17 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: Tue, 12 Jul 2011 16:26:51 +0000 (UTC) Injection-Info: mx04.eternal-september.org; posting-host="5HSAJfqnDjjLFxXZ6WBWEw"; logging-data="1561"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/1mixci32YPmhiE7e3DtMoYb7pQa8spPk=" User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:5.0) Gecko/20110624 Thunderbird/5.0 In-Reply-To: Cancel-Lock: sha1:JdXpgXbD0anVz+QOrV0UVs8gPzE= Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:6121 comp.lang.c:8176 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. You'd have to at least introduce some sort of global flag. int c = a + b; if( GLOBAL_OVERFLOW_FLAG ) { printf( "bugger..." ); }