[PATCH] D69145: Give readability-redundant-member-init an option IgnoreBaseInCopyConstructors to avoid breaking code with gcc -Werror=extra

Conrad Poelman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sat Oct 19 13:13:47 PDT 2019


poelmanc added a comment.

In D69145#1715614 <https://reviews.llvm.org/D69145#1715614>, @lebedev.ri wrote:

> So https://godbolt.org/z/qzjU-C
>  This feels like gcc being overly zealous, i'm not sure what it says with that warning.


I'd agree, while copy constructors //usually// need to copy base class information as well, and forgetting to do so //may// indicate a programming error, this warning may be more appropriate as a linter suggestion than a compiler warning. (Usually you'd want `: BaseClass(other)`; `: BaseClass()` is really just silencing the warning so you can handle `BaseClass` in the body of the copy constructor.)

That said, the warning appears to have been introduced in gcc 4.0 <http://gcc.gnu.org/onlinedocs/gcc-4.0.4/gcc/Warning-Options.html#Warning-Options> in 2005 <https://gcc.gnu.org/gcc-4.0/> so every modern version of gcc will produce this warning. So in practical terms the concerns raised by @mgehre are why I feel this option is needed.


Repository:
  rCTE Clang Tools Extra

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D69145/new/

https://reviews.llvm.org/D69145





More information about the cfe-commits mailing list