From: Pedro Alves <palves@redhat.com>
To: Gary Benson <gbenson@redhat.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [OB PATCH] Avoid testcase build failures with -Wunused-value
Date: Tue, 23 Jun 2020 12:53:04 +0100 [thread overview]
Message-ID: <296de4f4-c399-c6d5-f250-12b9c652e528@redhat.com> (raw)
In-Reply-To: <20200623114529.GA5308@blade.nx>
On 6/23/20 12:45 PM, Gary Benson wrote:
> Pedro Alves wrote:
>> On 6/23/20 12:26 PM, Gary Benson via Gdb-patches wrote:
>>> --- a/gdb/testsuite/gdb.cp/namespace.cc
>>> +++ b/gdb/testsuite/gdb.cp/namespace.cc
>>> @@ -150,22 +150,22 @@ namespace C
>>> // plan to have GDB try to print out, just to make sure that the
>>> // compiler and I agree which ones should be legal! It's easy
>>> // to screw up when testing the boundaries of namespace stuff.
>>> - c;
>>> + int unused1 = c;
>>
>> It looks like such a fix will only work until the compiler decides
>> to enable -Wunused-variable by default too:
>>
>> testsuite/gdb.cp/namespace.cc:153:11: warning: unused variable 'unused' [-Wunused-variable]
>> int unused = c;
>> ^
>>
>> Try compiling the testcase with -Wall, with both g++ and clang++:
>>
>> $ clang++ testsuite/gdb.cp/namespace.cc -Wall
>>
>> I think we should fix this with the more usual cast-to-void way:
>>
>> (void) c;
>
> Ok, but, out of interest, what stops the compiler ignoring that?
I don't know. That's a pattern people have been using ages,
it may be special cased.
Thanks,
Pedro Alves
next prev parent reply other threads:[~2020-06-23 11:53 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-23 11:26 Gary Benson
2020-06-23 11:41 ` Pedro Alves
2020-06-23 11:45 ` Gary Benson
2020-06-23 11:53 ` Pedro Alves [this message]
2020-06-23 14:13 ` [OB PATCH] Improve -Wunused-value testcase build failures fix Gary Benson
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=296de4f4-c399-c6d5-f250-12b9c652e528@redhat.com \
--to=palves@redhat.com \
--cc=gbenson@redhat.com \
--cc=gdb-patches@sourceware.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