This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: C++ PATCH for c++/88136, -Wdeprecated-copy too noisy


On Sat, Dec 8, 2018 at 12:17 PM Ville Voutilainen
<ville.voutilainen@gmail.com> wrote:
> On Sat, 8 Dec 2018 at 18:58, Jakub Jelinek <jakub@redhat.com> wrote:
> > > g++ -c -pipe -O2 -fPIC -std=c++1z -fvisibility=hidden
> > > -fvisibility-inlines-hidden -ffunction-sections -fdata-sections
> > > -fno-exceptions -Wall -W -Wvla -Wdate-time -Wshift-overflow=2
> >
> > -W is an alias to -Wextra.
>
> Yeah. Jason, I seem to have code that user-provides a copy constructor (seemingly for no particular reason),
> doesn't bother declaring a copy assignment operator, and still breaks magnificently. :) There is no bug
> in it; the assignment works as expected, so that's a false positive. I am going to suggest taking this warning
> out of -Wextra and making it completely separate for GCC 9.

The documented policy for -Wall is,

     This enables all the warnings about constructions that some users
     consider questionable, and that are easy to avoid (or modify to
     prevent the warning), even in conjunction with macros.
...
     Note that some warning flags are not implied by '-Wall'.  Some of
     them warn about constructions that users generally do not consider
     questionable, but which occasionally you might wish to check for;
     others warn about constructions that are necessary or hard to avoid
     in some cases, and there is no simple way to modify the code to
     suppress the warning.

It seems to me that this warning qualifies for -Wall under these
guidelines.  Providing a copy constructor without a matching
assignment operator is definitely suspect; the false positive only
comes in because, as you say, there was no good reason to provide the
copy constructor for Private.  And it's easy to avoid the warning by
declaring a defaulted assignment operator, if ABI concerns preclude
removing the constructor.

New compiler releases will usually include new warnings that require
some code modification to accommodate.  Why is this one particularly
problematic?

Jason


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]