public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* Re: c/6677: GCC 3.1 has a bug in signed char treatment
@ 2002-06-16 14:35 rth
  0 siblings, 0 replies; 3+ messages in thread
From: rth @ 2002-06-16 14:35 UTC (permalink / raw)
  To: gcc-bugs, gcc-prs, knu, nobody

Synopsis: GCC 3.1 has a bug in signed char treatment

State-Changed-From-To: analyzed->closed
State-Changed-By: rth
State-Changed-When: Sun Jun 16 13:55:49 2002
State-Changed-Why:
    http://gcc.gnu.org/ml/gcc-patches/2002-06/msg00435.html

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=6677


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: c/6677: GCC 3.1 has a bug in signed char treatment
@ 2002-05-21 11:43 neil
  0 siblings, 0 replies; 3+ messages in thread
From: neil @ 2002-05-21 11:43 UTC (permalink / raw)
  To: gcc-bugs, gcc-prs, knu, nobody

Synopsis: GCC 3.1 has a bug in signed char treatment

State-Changed-From-To: open->analyzed
State-Changed-By: neil
State-Changed-When: Tue May 21 11:43:02 2002
State-Changed-Why:
    Agreed.  Changed to high priority as this is a regression.

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=6677


^ permalink raw reply	[flat|nested] 3+ messages in thread

* c/6677: GCC 3.1 has a bug in signed char treatment
@ 2002-05-16  7:36 knu
  0 siblings, 0 replies; 3+ messages in thread
From: knu @ 2002-05-16  7:36 UTC (permalink / raw)
  To: gcc-gnats


>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:


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2002-06-16 20:55 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-06-16 14:35 c/6677: GCC 3.1 has a bug in signed char treatment rth
  -- strict thread matches above, loose matches on Subject: below --
2002-05-21 11:43 neil
2002-05-16  7:36 knu

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).