public inbox for gcc-prs@sourceware.org help / color / mirror / Atom feed
From: knu@iDaemons.org To: gcc-gnats@gcc.gnu.org Subject: c/6677: GCC 3.1 has a bug in signed char treatment Date: Thu, 16 May 2002 07:36:00 -0000 [thread overview] Message-ID: <20020516143229.18006.qmail@sources.redhat.com> (raw) >Number: 6677 >Category: c >Synopsis: GCC 3.1 has a bug in signed char treatment >Confidential: no >Severity: serious >Priority: medium >Responsible: unassigned >State: open >Class: wrong-code >Submitter-Id: net >Arrival-Date: Thu May 16 07:36:02 PDT 2002 >Closed-Date: >Last-Modified: >Originator: FreeBSD-gnats-submit@freebsd.org >Release: gcc (GCC) 3.1 [FreeBSD] 20020509 (prerelease) >Organization: >Environment: FreeBSD archon.local.idaemons.org 5.0-CURRENT FreeBSD 5.0-CURRENT #7: Mon May 6 01:19:19 JST 2002 root@archon.local.idaemons.org:/villa/work/obj/freebsd/src/villa/src/sys/ARCHON i386 gcc (GCC) 3.1 [FreeBSD] 20020509 (prerelease) >Description: GCC 3.1 has a bug in signed char treatment. See below. >How-To-Repeat: knu@archon[2]% cat a.c int main(void) { unsigned char i = 127; char j; printf("%d\n", ((char)(i << 1))); j = ((char)(i << 1)) / 2; printf("%d\n", j); j = ((char)(i << 1)); printf("%d\n", j / 2); return 0; } knu@archon[2]% cc a.c knu@archon[2]% ./a.out -2 127 -1 The second value should be equal to the third (-1). (char is signed on the platform) I can reproduce this with any of -O[0-6]. With gcc 2.95.x, this test code properly results in -2, -1 and -1. >Fix: Changing the division from `/ 2' to `>> 1' seems to work around the problem, but I don't know why. >Release-Note: >Audit-Trail: >Unformatted:
next reply other threads:[~2002-05-16 14:36 UTC|newest] Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top 2002-05-16 7:36 knu [this message] 2002-05-21 11:43 neil 2002-06-16 14:35 rth
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20020516143229.18006.qmail@sources.redhat.com \ --to=knu@idaemons.org \ --cc=gcc-gnats@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).