From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14857 invoked by alias); 3 Sep 2012 14:58:21 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 30652 Received: (qmail 25921 invoked from network); 3 Sep 2012 14:58:11 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW, SPF_HELO_PASS autolearn=ham version=3.3.2 Received-SPF: none (ns1.primenet.com.au: domain at csr.com does not designate permitted sender hosts) Date: Mon, 3 Sep 2012 15:57:32 +0100 From: Peter Stephenson To: Mikael Magnusson , Subject: Re: PATCH: prevent SIGFPE on systems where LONG_MIN < -LONG_MAX Message-ID: <20120903155732.6e0ed125@pwslap01u.europe.root.pri> In-Reply-To: References: Organization: Cambridge Silicon Radio X-Mailer: Claws Mail 3.7.9 (GTK+ 2.22.0; i386-redhat-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.101.10.18] X-Scanned-By: MailControl 8316.0 (www.mailcontrol.com) on 10.68.1.130 On Mon, 3 Sep 2012 16:40:37 +0200 Mikael Magnusson wrote: > See also this thread, > http://www.zsh.org/mla/workers/2011/msg00613.html >=20 > On 03/09/2012, J=C3=A9r=C3=A9mie Roquet wrote: > > Hello, > > > > $ echo $[ - 2**63 / -1 ] > > zsh: floating point exception ./Src/zsh > > > > $ echo $[ - 2**63 % -1 ] > > zsh: floating point exception ./Src/zsh > > > > The attached patch fixes this. >=20 >=20 > To report this email as spam click https://www.mailcontrol.com/sr/wQw0zm= jPoHdJTZGyOCrrhg=3D=3D . So what's the answer, then? J=C3=A9r=C3=A9mie's patch makes only limited assumptions; I think the #if is there simply to see if we can assume two's complement arithmetic (it seems the preprocessor isn't keen on "#if LONG_MIN - 1 =3D=3D LONG_MAX", I suppose it's not required to use "long" precision) in which case the test should work. It might not cover all real cases, but that's a lesser evil. --=20 Peter Stephenson Software Engineer Tel: +44 (0)1223 692070 Cambridge Silicon Radio Limited Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, = UK Member of the CSR plc group of companies. CSR plc registered in England and= Wales, registered number 4187346, registered office Churchill House, Cambr= idge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom More information can be found at www.csr.com. Follow CSR on Twitter at http= ://twitter.com/CSR_PLC and read our blog at www.csr.com/blog