public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "fredrik dot hederstierna at securitas-direct dot com" <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, 01 Dec 2008 12:56:00 -0000 [thread overview] Message-ID: <20081201125513.25441.qmail@sourceware.org> (raw) In-Reply-To: <bug-38341-17021@http.gcc.gnu.org/bugzilla/> ------- Comment #4 from fredrik dot hederstierna at securitas-direct dot com 2008-12-01 12:55 ------- Heres another example, then I do not think the warnings are due to optimization. I have same warnings with both -O0 and -O3. #include <stdio.h> typedef unsigned char u8_t; void test_cast(unsigned char c1, unsigned char c2, u8_t u1, u8_t u2) { if (c1 == (unsigned char)(~c2)) { printf("No warning"); } if (c1 == ~c2) { printf("This gives warning"); } if (u1 == (u8_t)(~u2)) { printf("This gives warning"); } if ((unsigned char)u1 == (unsigned char)(~u2)) { printf("This gives warning"); } } The original code that caused this warnings are the TCP/IP stack lwIP, then I constructed this minimal example. Original code from lwIP TCP/IP stack: ------------------------------------- static u8_t ip_reassbitmap[IP_REASS_BUFSIZE / (8 * 8) + 1]; static const u8_t bitmap_bits[8] = { 0xff, 0x7f, 0x3f, 0x1f, 0x0f, 0x07, 0x03, 0x01 }; /.../ if (ip_reassbitmap[ip_reasslen / (8 * 8)] != (u8_t) ~ bitmap_bits[ip_reasslen / 8 & 7]) { /.../ -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38341
next prev parent reply other threads:[~2008-12-01 12:56 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 [this message] 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 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=20081201125513.25441.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: linkBe 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).