]> gcc.gnu.org Git - gcc.git/commit
libstdc++: Set active member of union in std::string [PR103295]
authorJonathan Wakely <jwakely@redhat.com>
Wed, 17 Nov 2021 10:23:14 +0000 (10:23 +0000)
committerJonathan Wakely <jwakely@redhat.com>
Wed, 17 Nov 2021 17:21:25 +0000 (17:21 +0000)
commit6afa1083c6ee7b31629fb0c16299b952cb17868c
tree80ca1827605ce99fa1690f650cb3f707e857a363
parent054bf99841aad3869c70643b2ba2d9f85770c980
libstdc++: Set active member of union in std::string [PR103295]

Clang diagnoses that the new constexpr std::string constructors are not
usable in constant expressions, because they start to write to members
of the union without setting an active member.

This adds a new helper function which returns the address of the local
buffer after making it the active member.

This doesn't fix all problems with Clang, because it still refuses to
write to memory returned by the allocator.

libstdc++-v3/ChangeLog:

PR libstdc++/103295
* include/bits/basic_string.h (_M_use_local_data()): New
member function to make local buffer the active member.
(assign(const basic_string&)): Use it.
* include/bits/basic_string.tcc (_M_construct, reserve()):
Likewise.
libstdc++-v3/include/bits/basic_string.h
libstdc++-v3/include/bits/basic_string.tcc
This page took 0.078748 seconds and 6 git commands to generate.