From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15111 invoked by alias); 14 Oct 2002 14:36:04 -0000 Mailing-List: contact gcc-prs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-prs-owner@gcc.gnu.org Received: (qmail 15092 invoked by uid 71); 14 Oct 2002 14:36:03 -0000 Resent-Date: 14 Oct 2002 14:36:03 -0000 Resent-Message-ID: <20021014143603.15091.qmail@sources.redhat.com> Resent-From: gcc-gnats@gcc.gnu.org (GNATS Filer) Resent-Cc: gcc-prs@gcc.gnu.org, gcc-bugs@gcc.gnu.org Resent-Reply-To: gcc-gnats@gcc.gnu.org, mikulas@artax.karlin.mff.cuni.cz Received: (qmail 14051 invoked by uid 61); 14 Oct 2002 14:30:12 -0000 Message-Id: <20021014143012.14050.qmail@sources.redhat.com> Date: Mon, 14 Oct 2002 07:36:00 -0000 From: mikulas@artax.karlin.mff.cuni.cz Reply-To: mikulas@artax.karlin.mff.cuni.cz To: gcc-gnats@gcc.gnu.org X-Send-Pr-Version: gnatsweb-2.9.3 (1.1.1.1.2.31) Subject: c/8224: Incorrect joining of signed and unsigned division X-SW-Source: 2002-10/txt/msg00544.txt.bz2 List-Id: >Number: 8224 >Category: c >Synopsis: Incorrect joining of signed and unsigned division >Confidential: no >Severity: serious >Priority: medium >Responsible: unassigned >State: open >Class: wrong-code >Submitter-Id: net >Arrival-Date: Mon Oct 14 07:36:02 PDT 2002 >Closed-Date: >Last-Modified: >Originator: Mikulas Patocka >Release: gcc-2.7.2.3, gcc-2.95.4, gcc-3.0.4, gcc-3.2 >Organization: >Environment: Bug present in almost all gcc releases, tested on Linux and OS/2. >Description: When evaluating expressions like (unsigned)((int)x/2)/2, gcc incorrectly merges these two divisions into one signed (or unsigned in 2.7.2.3) division by 4, producing incorrect result. >How-To-Repeat: Compile and run the file. The bug can be seen with or without optimizations. >Fix: >Release-Note: >Audit-Trail: >Unformatted: ----gnatsweb-attachment---- Content-Type: application/octet-stream; name="bug-div.c" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="bug-div.c" dW5zaWduZWQgZihpbnQgeCkNCnsNCglyZXR1cm4gKHVuc2lnbmVkKSgoaW50KXgvMikvMjsNCn0N Cg0KdW5zaWduZWQgZjEoaW50IHgpDQp7DQoJdW5zaWduZWQgeHggPSB4LzI7DQoJcmV0dXJuIHh4 LzI7DQp9DQoNCm1haW4oKQ0Kew0KCXByaW50ZigiJWQgLSAlMDh4XG4iLCAtNSwgZjEoLTUpKTsN CglwcmludGYoIiVkIC0gJTA4eFxuIiwgLTUsIGYoLTUpKTsNCglyZXR1cm4gMDsNCn0NCg==