From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1971 invoked by alias); 4 Apr 2002 10:06: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 1949 invoked by uid 71); 4 Apr 2002 10:06:03 -0000 Resent-Date: 4 Apr 2002 10:06:03 -0000 Resent-Message-ID: <20020404100603.1948.qmail@sources.redhat.com> Resent-From: gcc-gnats@gcc.gnu.org (GNATS Filer) Resent-To: nobody@gcc.gnu.org Resent-Cc: gcc-prs@gcc.gnu.org, gcc-bugs@gcc.gnu.org Resent-Reply-To: gcc-gnats@gcc.gnu.org, jeroenk@allieddata.com Received:(qmail 1094 invoked by uid 61); 4 Apr 2002 10:03:33 -0000 Message-Id:<20020404100333.1093.qmail@sources.redhat.com> Date: Thu, 04 Apr 2002 02:06:00 -0000 From: jeroenk@allieddata.com Reply-To: jeroenk@allieddata.com To: gcc-gnats@gcc.gnu.org X-Send-Pr-Version:gnatsweb-2.9.3 (1.1.1.1.2.31) Subject: c/6170: Unsigned division bug in gcc 3.x X-SW-Source: 2002-04/txt/msg00297.txt.bz2 List-Id: >Number: 6170 >Category: c >Synopsis: Unsigned division bug in gcc 3.x >Confidential: no >Severity: serious >Priority: medium >Responsible: unassigned >State: open >Class: sw-bug >Submitter-Id: net >Arrival-Date: Thu Apr 04 02:06:01 PST 2002 >Closed-Date: >Last-Modified: >Originator: Jeroen Kappert >Release: gcc version 3.1 20020130 (Red Hat Linux Rawhide 3.1-0.19) >Organization: >Environment: Red Hat Linux 7.2 >Description: Unsigned division results into incorrect output. See the following code: --- #include int main(void) { signed short int sT = 3; unsigned short int uT = 3; signed int sV = sT / 10; unsigned int uV = uT / 10;; printf("Signed division : Value = %d (0x%04X) / 10 = %5d (0x%08X)\n", sT, sT, sV, sV); printf("Unsigned division : Value = %u (0x%04X) / 10 = %5u (0x%08X)\n", uT, uT, uV, uV); return 0; } --- Which results in the following output: ### Signed division : Value = 3 (0x0003) / 10 = 0 (0x00000000) Unsigned division : Value = 3 (0x0003) / 10 = 8191 (0x00001FFF) ### Note that the signed and unsigned devision differs! Now I compiled the same code (on another pc) with gcc version: gcc version 2.95.3 20010315 (SuSE) which gives the following output: ### Signed division : Value = 3 (0x0003) / 10 = 0 (0x00000000) Unsigned division : Value = 3 (0x0003) / 10 = 0 (0x00000000) ### Note that this is what i expected! It seems to me that there is a bug in gcc 3.x >How-To-Repeat: see description, to repeat the problem. >Fix: >Release-Note: >Audit-Trail: >Unformatted: