From: Ian Lance Taylor <iant@google.com>
To: Arnaud Lacombe <lacombar@gmail.com>
Cc: Steven Rostedt <rostedt@goodmis.org>,
gcc-help@gcc.gnu.org, stufever@gmail.com,
linux-kernel@vger.kernel.org,
Wang Shaoyan <wangshaoyan.pt@taobao.com>,
Frederic Weisbecker <fweisbec@gmail.com>,
Ingo Molnar <mingo@redhat.com>
Subject: Re: [PATCH] TRACING: Fix a copmile warning
Date: Mon, 25 Jul 2011 17:41:02 -0700 [thread overview]
Message-ID: <mcrfwltoov5.fsf@coign.corp.google.com> (raw)
In-Reply-To: <CACqU3MXO_oR+8Ac2Z7wSji0sUeu-2FwskmxZxtY9NV+XpJXuwA@mail.gmail.com> (Arnaud Lacombe's message of "Mon, 25 Jul 2011 19:50:26 -0400")
Arnaud Lacombe <lacombar@gmail.com> writes:
> gcc will only emits the warning at -Os. It seems to me that the
> resulting code clearly ends-up testing an uninitialized value, ie.
> assuming the following test-case:
>
> extern void *e(void);
> extern void *f(void);
> extern void g(void);
>
> void fn(void)
> {
> void *b, *a;
>
> a = e();
> if (a != 0)
> b = f();
> if (a != 0 && b != 0)
> g();
> }
>
> ...
>
> It seems gcc transforms the conditional from:
>
> if (a != NULL && b != NULL) ...
>
> to
>
> if (b != NULL && a != NULL) ...
>
> In which case the warning is fully valid. I'm not sure what's the C
> standard guarantee in term of conditional test order. gcc 4.7.0 has
> the same behavior.
Not quite. C guarantees that && is executed in order. In this case gcc
is generating
a = e();
if (a != NULL)
b = f();
if (a != NULL & b != NULL)
g();
Note the change from && to & in the last conditional. This
transformation is safe, in that it does not change the meaning of the
program. However, it does cause a read of an uninitialized memory
location, and this is causing a later gcc pass to generate a false
positive warning.
Please consider filing a bug report about this false positive. Thanks.
Ian
next prev parent reply other threads:[~2011-07-26 0:41 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-07-18 9:40 [PATCH] TRACING: Fix a copmile warning stufever
2011-07-25 18:32 ` Steven Rostedt
2011-07-25 19:43 ` Arnaud Lacombe
2011-07-25 20:19 ` Steven Rostedt
2011-07-25 20:28 ` Arnaud Lacombe
2011-07-25 22:38 ` Arnaud Lacombe
2011-07-25 23:49 ` Steven Rostedt
2011-07-25 23:52 ` Arnaud Lacombe
2011-07-26 0:14 ` Steven Rostedt
2011-07-25 23:50 ` Arnaud Lacombe
2011-07-25 23:58 ` Arnaud Lacombe
2011-07-26 0:08 ` Steven Rostedt
2011-07-26 0:35 ` Steven Rostedt
2011-07-26 0:44 ` Ian Lance Taylor
2011-07-26 0:41 ` Ian Lance Taylor [this message]
2011-07-26 1:08 ` Arnaud Lacombe
2011-07-26 1:12 ` Steven Rostedt
2011-07-26 1:19 ` Arnaud Lacombe
2011-07-26 20:43 ` Jeff Law
2011-07-26 1:10 ` Steven Rostedt
2011-07-26 5:55 ` Ian Lance Taylor
2011-07-26 12:00 ` Paulo Marques
2011-07-26 13:18 ` Jesper Juhl
2011-07-26 13:32 ` Paulo Marques
2011-07-26 13:55 ` Steven Rostedt
-- strict thread matches above, loose matches on Subject: below --
2011-07-18 9:35 stufever
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=mcrfwltoov5.fsf@coign.corp.google.com \
--to=iant@google.com \
--cc=fweisbec@gmail.com \
--cc=gcc-help@gcc.gnu.org \
--cc=lacombar@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=rostedt@goodmis.org \
--cc=stufever@gmail.com \
--cc=wangshaoyan.pt@taobao.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.