From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21148 invoked by alias); 12 Apr 2006 01:14:59 -0000 Received: (qmail 21124 invoked by uid 48); 12 Apr 2006 01:14:56 -0000 Date: Wed, 12 Apr 2006 01:14:00 -0000 Message-ID: <20060412011456.21123.qmail@sourceware.org> X-Bugzilla-Reason: CC References: Subject: [Bug c/27116] [4.2 Regression] Incorrect integer division (wrong sign). In-Reply-To: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "pinskia at gcc dot gnu dot org" Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2006-04/txt/msg00913.txt.bz2 List-Id: ------- Comment #8 from pinskia at gcc dot gnu dot org 2006-04-12 01:14 ------- GRRRRRRR. This is partly caused by the patch for PR 23669. (In reply to comment #7) > > I disagree. Could you give an explicit example? > Sorry, my mistake, I should not have suggested this testcase: this optimization > is indeed fine (yet GCC 4.1 does not apply it). The following testcase is not > fine though (directly derived from the original testcase): > int f(int a, int b) { return (-1 - a) / (-b); } > GCC 4.2 generates the division "(a + 1) / b". This optimization is wrong when > "a" contains the biggest positive integer. This is undefined only if b is known to be negative otherwise it is defined. Note I cannot patch anything right now so if someone wants to revert my patch that is fine. -- pinskia at gcc dot gnu dot org changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |pinskia at gcc dot gnu dot | |org OtherBugsDependingO| |23669 nThis| | Known to work|4.1.0 4.0.3 | Target Milestone|--- |4.2.0 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27116