https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113294
--- Comment #3 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Patrick Palka <ppa...@gcc.gnu.org>: https://gcc.gnu.org/g:065dddc6e07a917c57c7955db13b1fe77abbcabc commit r14-8943-g065dddc6e07a917c57c7955db13b1fe77abbcabc Author: Paul Keir <paul.k...@uws.ac.uk> Date: Mon Feb 12 18:15:49 2024 +0000 libstdc++: Fix constexpr basic_string union member [PR113294] A call to `basic_string::clear()` in the std::string move assignment operator leads to a constexpr error from an access of inactive union member `_M_local_buf` in the added test (`test_move()`). Changing `__str._M_local_buf` to `__str._M_use_local_data()` in `operator=(basic_string&& __str)` fixes this. PR libstdc++/113294 libstdc++-v3/ChangeLog: * include/bits/basic_string.h (basic_string::operator=): Use _M_use_local_data() instead of _M_local_buf on the moved-from string. * testsuite/21_strings/basic_string/modifiers/constexpr.cc (test_move): New test. Signed-off-by: Paul Keir <paul.k...@uws.ac.uk> Reviewed-by: Patrick Palka <ppa...@redhat.com> Reviewed-by: Jonathan Wakely <jwak...@redhat.com>