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] |
We optimize _Destroy and _Destroy_n to do nothing when the type has a trivial destructor, which means we do nothing (instead of giving an error) when trying to destroy types with deleted destructors. Because deleted destructors are trivial. Because C++. This adds static assertions to reject attempts to destroy indestructible objects. I put them in the top-level functions, not the specialization for trivial destructors, which means we also get the static assertion for types with a private destructor. It's debatable whether that's better: you get a failed "type is destructible" assertion instead of an error saying the destructor is private, which is a bit more precise. If people prefer the compiler error about a private destructor we could move the assertions into the specializations for types with trivial destructors. PR libstdc++/80553 * include/bits/stl_construct.h (_Destroy, _Destroy_n): Add static assertions to ensure type is destructible. (destroy_at, destroy, destroy_n): Move from stl_uninitialized.h. * include/bits/stl_uninitialized.h (destroy_at, destroy, destroy_n): Move to stl_construct.h. * testsuite/20_util/specialized_algorithms/memory_management_tools/ destroy_neg.cc: New test. * testsuite/23_containers/vector/cons/destructible_neg.cc: New test. Tested powerpc64le-linux, committed to trunk.
Attachment:
patch.txt
Description: Text document
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |