From: John Snow <jsnow@redhat.com>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: qemu-devel <qemu-devel@nongnu.org>,
Stefan Hajnoczi <stefanha@redhat.com>
Subject: Re: [Qemu-devel] clang 3.5.0 errors
Date: Wed, 18 Mar 2015 18:22:00 -0400 [thread overview]
Message-ID: <5509FA88.3000201@redhat.com> (raw)
In-Reply-To: <CAFEAcA-SG4shPLfpesw1ovp97UdsNVR0HNuh=eK+RcRSnY0sjA@mail.gmail.com>
On 03/18/2015 04:28 PM, Peter Maydell wrote:
> On 18 March 2015 at 19:22, John Snow <jsnow@redhat.com> wrote:
>> There's one case of error here that's interesting that ccache unearths:
>>
>> we use a gnu extension to give return values to compound statement blocks,
>> then wrap these blocks into macros as if they were functions.
>>
>> The practical outcome here is that these blocks have return codes that we
>> often don't check, so clang will spit out "unused value" warnings if we
>> compile these after preprocessing, like ccache will tend to do.
>>
>> This warning is potentially valid: if these calls can fail, we should
>> probably either be asserting that a failure did not occur OR we should
>> switch to a variant without a return code, if failure is impossible in these
>> locations.
>>
>> An example of this is in linux-user/elfload.c where we define the
>> NEW_AUX_ENT() macro which in turn uses the put_user_ual(val, sp) macro. When
>> this is expanded, it turns into a compound statement where we discard the
>> expression result, so clang whines.
>>
>> Of course, this all goes away if you disable ccache, but is it worth
>> adjusting this particular usage anyway?
>
> I agree that ideally we wouldn't do that, but why is this
> only visible via ccache? If ccache creates warnings that
> aren't visible when directly running the c compiler then
> that's a bug in ccache even if the warnings are in theory
> interesting.
>
You're asking the hard questions.
My hunch is that when the macro is functionaized like it is, clang's
static analysis treats it as such and decides not to warn about not
checking the return code, much like it won't for real functions.
When it's flattened, it loses its semantic nature as a function and it
becomes more of a "useless statement" warning.
It's definitely a bug in ccache, clang or both.
I just found this particular instance of a ccache-provoked warning
interesting because it does have some validity to it and I wanted to
raise the issue.
If nobody cares, then, well. Nobody cares.
More mechanical, less-interesting clang fixes will hit the list shortly.
--js
next prev parent reply other threads:[~2015-03-18 22:22 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-17 19:30 [Qemu-devel] clang 3.5.0 errors John Snow
2015-03-17 19:34 ` Peter Maydell
2015-03-17 19:59 ` John Snow
2015-03-17 23:07 ` Peter Maydell
2015-03-18 19:22 ` John Snow
2015-03-18 20:28 ` Peter Maydell
2015-03-18 22:22 ` John Snow [this message]
2015-03-18 22:48 ` Peter Maydell
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=5509FA88.3000201@redhat.com \
--to=jsnow@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.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 NNTP newsgroup(s).