[Bug c++/109740] -Woverloaded-virtual is too aggressive
emerg.reanimator at gmail dot com
gcc-bugzilla@gcc.gnu.org
Wed Nov 1 18:04:39 GMT 2023
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109740
Alexander Goomenuk <emerg.reanimator at gmail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |emerg.reanimator at gmail dot com
--- Comment #3 from Alexander Goomenuk <emerg.reanimator at gmail dot com> ---
Let consider the following case:
- There is a base class that implement virtual assignment operator with
arbitrary input argument (not copy operator).
- There is a derived class that inherits the assignment operator from base
class.
g++ version >= 13 produces the warning in this case because implicitly-defined
copy operator of derived class pretends to hide the user defined assignment
operator of base class. The code is totally fine and the assignment operator
works as expected.
Even worse, the warning is produced by compiler even if no implicitly-defined
copy operator is NOT generated by the compiler and the code fails to build due
to the lack of copy operator. So the warning is misleading and incorrect in
this case.
See
https://stackoverflow.com/questions/77378553/woverloaded-virtual-with-default-shallow-copy-operator
for more details.
More information about the Gcc-bugs
mailing list