public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
From: mikulas@artax.karlin.mff.cuni.cz
To: gcc-gnats@gcc.gnu.org
Subject: c/8224: Incorrect joining of signed and unsigned division
Date: Mon, 14 Oct 2002 07:36:00 -0000	[thread overview]
Message-ID: <20021014143012.14050.qmail@sources.redhat.com> (raw)


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


             reply	other threads:[~2002-10-14 14:36 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-10-14  7:36 mikulas [this message]
2003-02-02 23:15 bangerth
2003-03-15 21:56 Glen Nakamura
2003-03-22  8:56 Glen Nakamura
2003-03-23 19:16 Glen Nakamura
2003-03-23 23:06 mmitchel

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=20021014143012.14050.qmail@sources.redhat.com \
    --to=mikulas@artax.karlin.mff.cuni.cz \
    --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: link
Be 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).