[Bug libstdc++/120390] [12/13/14/15/16 Regression] Request to improve error with private destructor
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120390 --- Comment #9 from GCC Commits --- The master branch has been updated by Jonathan Wakely : https://gcc.gnu.org/g:01789efaea25a48ac45dae8facb6db8abd8ebb14 commit r16-1412-g01789efaea25a48ac45dae8facb6db8abd8ebb14 Author: Jonathan Wakely Date: Wed May 21 23:48:34 2025 +0100 libstdc++: Improve diagnostics for ill-formed std::_Destroy and std::_Destroy_n [PR120390] By using std::is_trivially_destructible instead of the old __has_trivial_destructor built-in we no longer need the static_assert to deal with types with deleted destructors. All non-destructible types, including those with deleted destructors, will now give user-friendly diagnostics that clearly explain the problem. Also combine the _Destroy_aux and _Destroy_n_aux class templates used for C++98 into one, so that we perform fewer expensive class template instantiations. libstdc++-v3/ChangeLog: PR libstdc++/120390 * include/bits/stl_construct.h (_Destroy_aux::__destroy_n): New static member function. (_Destroy_aux::__destroy_n): Likewise. (_Destroy_n_aux): Remove. (_Destroy(ForwardIterator, ForwardIterator)): Remove static_assert. Use is_trivially_destructible instead of __has_trivial_destructor. (_Destroy_n): Likewise. Use _Destroy_aux::__destroy_n instead of _Destroy_n_aux::__destroy_n. * testsuite/20_util/specialized_algorithms/memory_management_tools/destroy_neg.cc: Adjust dg-error strings. Move destroy_n tests to ... * testsuite/20_util/specialized_algorithms/memory_management_tools/destroy_n_neg.cc: New test. * testsuite/23_containers/vector/cons/destructible_debug_neg.cc: Adjust dg-error strings. * testsuite/23_containers/vector/cons/destructible_neg.cc: Likewise. Reviewed-by: Tomasz KamiÅski
[Bug libstdc++/120390] [12/13/14/15/16 Regression] Request to improve error with private destructor
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120390
Jonathan Wakely changed:
What|Removed |Added
Keywords||patch
--- Comment #8 from Jonathan Wakely ---
With https://gcc.gnu.org/pipermail/gcc-patches/2025-June/686306.html the
static_assert failure is replaced with:
/home/jwakely/gcc/16/include/c++/16.0.0/bits/stl_construct.h:166:22: error:
'MovieData::~MovieData()' is private within this context
166 | __pointer->~_Tp();
| ~~~^~
dest.cc:5:5: note: declared private here
5 | ~MovieData(){}
| ^
[Bug libstdc++/120390] [12/13/14/15/16 Regression] Request to improve error with private destructor
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120390 Jonathan Wakely changed: What|Removed |Added Status|NEW |ASSIGNED Target Milestone|--- |12.5 Known to fail||15.1.0, 7.5.0 Priority|P3 |P4 Severity|normal |minor Assignee|unassigned at gcc dot gnu.org |redi at gcc dot gnu.org Summary|Request to improve error|[12/13/14/15/16 Regression] |with private destructor |Request to improve error ||with private destructor Known to work||6.5.0 --- Comment #7 from Jonathan Wakely --- I pulled at this thread and ended up unravelling parts of std::vector (Bug 94831, Bug 40192, Bug 120397) I'm just going to make a minimal change for this which would be suitable for backports, because this is a diagnostic regression. Then I'll rewrite std::_Destroy and std::_Destroy_n on trunk, after deprecating support for std::vector which should never have been supported in the first place.
