From: Zoltan Kocsi <zoltan@bendor.com.au>
To: gcc@gcc.gnu.org
Subject: Signed-unsigned comparison question
Date: Thu, 07 Mar 2019 23:40:00 -0000 [thread overview]
Message-ID: <20190308104006.727e495f@linux-o3yw> (raw)
Gcc 8.2.0 (arm-none-eabi) throws a warning on the following construct:
uint32_t a;
uint16_t b;
if ( a > b ) ...
compaining that a signed integer is compared against an unsigned.
Of course, it is correct, as 'b' was promoted to int.
But shouldn't it be smart enough to know that (int) b is restricted to
the range of [0,65535] which it can safely compare against the range of
[0,0xffffffffu]?
Thanks,
Zoltan
next reply other threads:[~2019-03-07 23:40 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-03-07 23:40 Zoltan Kocsi [this message]
2019-03-07 23:53 ` Zoltan Kocsi
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=20190308104006.727e495f@linux-o3yw \
--to=zoltan@bendor.com.au \
--cc=gcc@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).