Skip to content
Snippets Groups Projects
Commit 065dddc6 authored by Paul Keir's avatar Paul Keir Committed by Patrick Palka
Browse files

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: default avatarPaul Keir <paul.keir@uws.ac.uk>
Reviewed-by: default avatarPatrick Palka <ppalka@redhat.com>
Reviewed-by: default avatarJonathan Wakely <jwakely@redhat.com>
parent 39d98902
No related branches found
No related tags found
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment