libstdc++: Ensure active union member is correctly set
commit28adad7a32ed92a3c0906b38411c4ed686bbacc5
authorNathaniel Shead <nathanieloshead@gmail.com>
Fri, 29 Sep 2023 09:30:41 +0000 (29 10:30 +0100)
committerJonathan Wakely <jwakely@redhat.com>
Fri, 29 Sep 2023 15:01:20 +0000 (29 16:01 +0100)
tree8836eef97fb7e199326ea72221bb32dfb26dba80
parent346f5991569faeb9995ac12100c2afba46ab6437
libstdc++: Ensure active union member is correctly set

This patch ensures that the union members for std::string and
std::variant are always properly set when a change occurs.

libstdc++-v3/ChangeLog:

* include/bits/basic_string.h: (basic_string(basic_string&&)):
Activate _M_local_buf when needed.
(basic_string(basic_string&&, const _Alloc&)): Likewise.
* include/bits/basic_string.tcc: (basic_string::swap): Likewise.
* include/std/variant: (__detail::__variant::__construct_n): New.
(__detail::__variant::__emplace): Use __construct_n.

Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
libstdc++-v3/include/bits/basic_string.h
libstdc++-v3/include/bits/basic_string.tcc
libstdc++-v3/include/std/variant