From: Marek Polacek <polacek@redhat.com>
To: Gerald Pfeifer <gerald@pfeifer.com>
Cc: gcc-patches@gcc.gnu.org
Subject: Re: [C/C++ PATCH] Improve -Wlogical-op (PR c/63357)
Date: Mon, 27 Apr 2015 14:47:00 -0000 [thread overview]
Message-ID: <20150427144712.GA8489@redhat.com> (raw)
In-Reply-To: <alpine.LSU.2.20.1504252146530.3191@tuna.site>
On Sat, Apr 25, 2015 at 10:18:59PM +0200, Gerald Pfeifer wrote:
> In case this example feels too contrived (even though it is an
> excerpt of Wine code), we now also warn about the following where
> the two types and variables are defined in different places and
> the size of one is set implicitly:
>
> typedef int r_fun_t (int);
>
> r_fun_t * text_funcs[] = {0,0,0};
>
> int report (unsigned t)
> {
> typedef int s_fun_t (long, char);
>
> static s_fun_t * GUI_funcs[3];
>
> return (t < sizeof text_funcs / sizeof text_funcs[0] &&
> t < sizeof GUI_funcs / sizeof GUI_funcs[0]);
> }
>
> (I also filed this as https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65891
> so that we keep track.)
I'm afraid there isn't an easy solution to this; the problem is that we fold
sizeof early, so the warning sees
t < sizeof 4 && t < 4
and warns. Maybe using SIZEOF_EXPR would help...
Marek
next prev parent reply other threads:[~2015-04-27 14:47 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-25 20:19 Gerald Pfeifer
2015-04-27 14:47 ` Marek Polacek [this message]
2015-04-27 14:50 ` Marek Polacek
2015-04-27 16:06 ` Jeff Law
2015-04-27 16:10 ` Marek Polacek
-- strict thread matches above, loose matches on Subject: below --
2015-04-21 11:16 Marek Polacek
2015-04-21 14:19 ` Manuel López-Ibáñez
2015-04-22 8:59 ` Marek Polacek
2015-04-22 9:51 ` Manuel López-Ibáñez
2015-04-22 9:54 ` Manuel López-Ibáñez
2015-04-22 11:12 ` Marek Polacek
2015-04-23 22:02 ` Jeff Law
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=20150427144712.GA8489@redhat.com \
--to=polacek@redhat.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=gerald@pfeifer.com \
/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).