Re: [PATCH 0/3] Fix various C++ related clang warnings

John Baldwin
2016-11-23T23:23:50Z

On Wednesday, November 23, 2016 05:18:28 PM Simon Marchi wrote:
> On 2016-11-23 15:06, John Baldwin wrote:
> > These patches fix various new C++ warnings reported by clang 3.8.0.
> > The last one regarding std::move is a bit surprising I think, but
> > there's a not-bad answer to a similar issue here:
> >
> > http://stackoverflow.com/questions/19267408/why-does-stdmove-prevent-rvo
> >
> > John Baldwin (3):
> > Fix mismatched struct vs class tags.
> > Add noexcept to custom non-throwing new operators.
> > Do not use std::move when assigning an anonymous object to a
> > unique_ptr.
>
> Hi John,
>
> When I tried to build gdb and gdbserver on Linux with clang, I got many
> more warnings/errors (often relevant). I assume you have many more
> fixups to do to actually get it building on FreeBSD with clang?

I build without -Werror when using clang. There are several more warnings
beyond these. One set in particular is a set of -Wunused-function that
get generated by VEC(). My understanding is that VEC() will be replaced by
templates at some point which will trim many of the current clang warnings.
There are several tautological compare warnings due to doing
'if (foo >= 0 && foo <= X)' when 'foo' is unsigned (the comparison against
0 is always true in that case). However, I sometimes think that listing
the explicit bounds can be useful to the reader in those cases so have
been hesitant to change those. One option we could take is to provide
different WARN_CFLAGS for GCC vs clang, but I haven't sat down to figure out
how to do that. I do try to fix the warnings that I think are relevant
however (such as in this set).

--
John Baldwin