[OB PATCH] Avoid testcase build failures with -Wunused-value
Gary Benson
gbenson@redhat.com
Tue Jun 23 11:45:29 GMT 2020
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?
Thanks,
Gary
More information about the Gdb-patches
mailing list