public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "john dot carter at tait dot co dot nz" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c/38341] Wrong warning comparison of promoted ~unsigned with unsigned
Date: Mon, 23 Feb 2009 23:53:00 -0000 [thread overview]
Message-ID: <20090223235318.23413.qmail@sourceware.org> (raw)
In-Reply-To: <bug-38341-17021@http.gcc.gnu.org/bugzilla/>
------- Comment #7 from john dot carter at tait dot co dot nz 2009-02-23 23:53 -------
R Guenther said...
> (int)u1 == (int)(u8_t)(~(int)u2)
>
> that we do not warn for the first case is because it is optimized to
> u1 == ~u2 before.
>
> Why do you think the warning is incorrect?
-----------------------------------------------
I would expect
u2 to be promoted to a 4 byte int
~ to do the ones complement on a 4 byte int
(unsigned char)~u2 to truncate to one byte discarding the most significant 3
bytes
and then the result get promoted to an int to evaluate the ==
ie. The cast cannot get optimized away, it's not a null op, it discards the
most significant bytes.
ie. (int)(unsigned char)~(int)u2 is not equivalent to
~(int)u2
ie. This is a bug
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38341
next prev parent reply other threads:[~2009-02-23 23:53 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-12-01 8:36 [Bug c/38341] New: " fredrik dot hederstierna at securitas-direct dot com
2008-12-01 10:02 ` [Bug c/38341] " rguenth at gcc dot gnu dot org
2008-12-01 12:41 ` fredrik dot hederstierna at securitas-direct dot com
2008-12-01 12:50 ` rguenth at gcc dot gnu dot org
2008-12-01 12:56 ` fredrik dot hederstierna at securitas-direct dot com
2008-12-01 13:36 ` fredrik dot hederstierna at securitas-direct dot com
2008-12-02 12:15 ` rguenth at gcc dot gnu dot org
2009-02-23 23:53 ` john dot carter at tait dot co dot nz [this message]
2009-02-24 0:40 ` michael dot malone at tait dot co dot nz
2009-02-24 0:43 ` michael dot malone at tait dot co dot nz
[not found] <bug-38341-4@http.gcc.gnu.org/bugzilla/>
2014-01-29 16:01 ` gjl at gcc dot gnu.org
2023-05-20 4:26 ` pinskia at gcc dot gnu.org
2023-06-29 14:52 ` wolter.hellmundvega at tevva dot com
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=20090223235318.23413.qmail@sourceware.org \
--to=gcc-bugzilla@gcc.gnu.org \
--cc=gcc-bugs@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).