[Bug c++/58407] [C++11] Should warn about deprecated implicit generation of copy constructor/assignment
jason at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Wed May 16 01:22:00 GMT 2018
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58407
Jason Merrill <jason at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Attachment #43637|0 |1
is obsolete| |
--- Comment #14 from Jason Merrill <jason at gcc dot gnu.org> ---
Created attachment 44135
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=44135&action=edit
updated patch
Here's an updated implementation, which is limited to -Wall, so it doesn't
affect the building or testing of the library. I'm sure you will still want to
adjust the library to avoid warnings when users try to build with -Wall.
On looking more closely at some of the places I was getting warnings in the
compiler, I noticed that they often seemed to be actual errors. For instance,
if someone copies an aa_tree and then destroys one of the aa_trees, the other
is left with a pointer to garbage.
I also realized that we want to avoid warning when the copy is elided,
particularly given C++17 mandatory copy elision; if the prvalue directly
initializes a variable, there's no problematic copying.
An interesting subcategory I noticed when I had the warning on by default is
classes with a virtual destructor, such as the exception hierarchy. The
warning calls attention to potential slicing problems, and so I think we don't
want to add defaulted copy ops; it's good for users to be encouraged to e.g.
catch by reference.
More information about the Gcc-bugs
mailing list