Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id EF4F11337BB0 for ; Fri, 11 Mar 2011 18:53:22 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 63969-01 for ; Fri, 11 Mar 2011 22:53:13 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by mail.postgresql.org (Postfix) with ESMTP id 3C3651337BA3 for ; Fri, 11 Mar 2011 18:53:12 -0400 (AST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.2/8.14.2) with ESMTP id p2BMr2g7000259; Fri, 11 Mar 2011 17:53:02 -0500 (EST) To: Martin Pitt cc: PostgreSQL Bugs , Aurelien Jarno , 616180@bugs.debian.org Subject: Re: [patch] test failure on sparc64 due to undefined division by zero behaviour In-reply-to: <20110311174710.GF2541@piware.de> References: <20110311174710.GF2541@piware.de> Comments: In-reply-to Martin Pitt message dated "Fri, 11 Mar 2011 18:47:10 +0100" Date: Fri, 11 Mar 2011 17:53:02 -0500 Message-ID: <258.1299883982@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.91 tagged_above=-5 required=5 tests=BAYES_00=-1.9, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201103/210 X-Sequence-Number: 29720 Martin Pitt writes: > The C99 standard [2], section 6.5.5 paragraph 5 actually says: > "The result of the / operator is the quotient from the division of > the first operand by the second; the result of the % operator is the > remainder. In both operations, if the value of the second operand is > zero, the behavior is undefined." > so the gcc folk's claim that this isn't a gcc bug looks justified. The gcc guys are full of it. The issue that is relevant here is the C standard's definition of sequence points, and in particular the requirement that visible side effects of a later statement cannot happen before the execution of an earlier function call. The last time I pestered them about this, I got some lame claim that a SIGFPE wasn't a side effect within the definitions of the spec. At that point useful discussion stopped, because it's impossible to negotiate with someone who's willing to claim that. > Aurelien sent a straightforward patch for this, I updated it to apply > to current git head, updated the comments, and git-formatted it. Hmm ... I'm willing to put in the extra return statements, but not to remove the comments that we're working around a gcc bug. In particular, given the gcc folks' claim that they need not consider the timing of program-generated signals, there is really nothing to stop them from trying to push the division up before the return too. This is nothing but a band-aid for a non-standards-compliant optimizer. regards, tom lane