This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

c/8224: Incorrect joining of signed and unsigned division


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]