gcc/libstdc++-v3/include/std
Jonathan Wakely e27771e5dc libstdc++: Remove try/catch overhead in std::variant::emplace
The __variant_construct_by_index helper function sets the new index
before constructing the new object. This means that if the construction
throws then the exception needs to be caught, so the index can be reset
to variant_npos, and then the exception rethrown. This means callers are
responsible for restoring the variant's invariants and they need the
overhead of a catch handler and a rethrow.

If we don't set the index until after construction completes then the
invariant is never broken, and callers can ignore the exception and let
it propagate. The callers all call _M_reset() first, which sets index to
variant_npos as required while the variant is valueless.

We need to be slightly careful here, because changing the order of
operations in __variant_construct_by_index and removing the try-block
from variant::emplace<I> changes an implicit ABI contract between those
two functions. If the linker were to create an executable containing an
instantiation of the old __variant_construct_by_index and an
instantiation of the new variant::emplace<I> code then we would have a
combination that breaks the invariant and doesn't have the exception
handling to restore it. To avoid this problem, we can rename the
__variant_construct_by_index function so that the new emplace<I> code
calls a new symbol, and is unaffected by the behaviour of the old
symbol.

libstdc++-v3/ChangeLog:

	* include/std/variant (__detail::__variant::__get_storage):
	Remove unused function.
	(__variant_construct_by_index): Set index after construction is
	complete. Rename to ...
	(__detail::__variant::__construct_by_index): ... this.
	(variant): Use new name for __variant_construct_by_index friend
	declaration. Remove __get_storage friend declaration.
	(variant::emplace): Use new name and remove try-blocks.
2021-10-15 18:26:53 +01:00
..
algorithm libstdc++: Remove unnecessary uses of <utility> 2021-07-27 12:04:18 +01:00
any libstdc++: Simplify constraints for std::any construction 2021-10-05 15:56:56 +01:00
array libstdc++: Add [[nodiscard]] to sequence containers 2021-08-04 12:54:29 +01:00
atomic libstdc++: Implement std::atomic<T*>::compare_exchange_weak 2021-09-02 18:22:33 +01:00
barrier [libstdc++] Remove unused hasher instance. 2021-06-08 15:41:31 -07:00
bit libstdc++: Fix <bit> to work freestanding [PR 100060] 2021-04-13 17:54:03 +01:00
bitset libstdc++: Fix doxygen markup for group close commands 2021-04-06 16:43:24 +01:00
charconv libstdc++: Don't check always-true condition [PR101965] 2021-08-19 14:57:41 +01:00
chrono libstdc++: Implement ostream insertion for chrono::duration 2021-10-08 12:19:19 +01:00
codecvt Update copyright years. 2021-01-04 10:26:59 +01:00
complex libstdc++: Simplify n-ary arithmetic promotion traits 2021-08-18 14:26:39 +01:00
concepts libstdc++: Implement LWG 3557 change to convertible_to 2021-06-18 11:51:33 -04:00
condition_variable libstdc++: Move C++14 <chrono> components to new <bits/chrono.h> header 2021-10-07 21:12:32 +01:00
coroutine libstdc++: Make coroutine_handle<_Promise>::from_address() noexcept [PR 99021] 2021-02-09 12:31:52 +00:00
deque libstdc++: Restore debug checks in uniform container erasure functions 2021-10-08 12:20:25 +01:00
execution Update copyright years. 2021-01-04 10:26:59 +01:00
filesystem Update copyright years. 2021-01-04 10:26:59 +01:00
forward_list Update copyright years. 2021-01-04 10:26:59 +01:00
fstream libstdc++: Fix doxygen markup for group close commands 2021-04-06 16:43:24 +01:00
functional libstdc++: Implement std::move_only_function for C++23 (P0288R9) 2021-10-06 20:12:01 +01:00
future libstdc++: Reduce headers included by <future> 2021-07-23 13:27:45 +01:00
iomanip Update copyright years. 2021-01-04 10:26:59 +01:00
ios Update copyright years. 2021-01-04 10:26:59 +01:00
iosfwd Update copyright years. 2021-01-04 10:26:59 +01:00
iostream libstdc++: Fix doxygen markup for group close commands 2021-04-06 16:43:24 +01:00
istream libstdc++: Fix constraints for rvalue stream insertion/extraction 2021-05-07 23:45:52 +01:00
iterator Update copyright years. 2021-01-04 10:26:59 +01:00
latch libstdc++: Fix whitespace in license boilerplate 2021-04-21 12:59:58 +01:00
limits libstdc++: Use __extension__ instead of diagnostic pragmas 2021-07-16 15:03:03 +01:00
list Update copyright years. 2021-01-04 10:26:59 +01:00
locale Update copyright years. 2021-01-04 10:26:59 +01:00
map libstdc++: Restore debug checks in uniform container erasure functions 2021-10-08 12:20:25 +01:00
memory libstdc++: Remove garbage collection support for C++23 [P2186R2] 2021-06-22 20:58:43 +01:00
memory_resource libstdc++: Specialize allocator_traits<pmr::polymorphic_allocator<T>> 2021-08-03 15:30:36 +01:00
mutex libstdc++: Move C++14 <chrono> components to new <bits/chrono.h> header 2021-10-07 21:12:32 +01:00
numbers Update copyright years. 2021-01-04 10:26:59 +01:00
numeric libstdc++: Replace incorrect static assertion in std::reduce [PR95833] 2021-06-18 14:46:58 +01:00
optional libstdc++: Add missing constexpr to std::optional (P2231R1) 2021-10-14 09:08:01 +01:00
ostream libstdc++: Define deleted wchar_t overloads unconditionally [PR 98725] 2021-10-09 00:57:50 +01:00
queue Update copyright years. 2021-01-04 10:26:59 +01:00
random Update copyright years. 2021-01-04 10:26:59 +01:00
ranges libstdc++: Add std::__conditional_t alias template 2021-10-01 20:34:49 +01:00
ratio libstdc++: Suppress redundant definitions of inline variables 2021-08-03 15:41:11 +01:00
regex libstdc++: Reduce use of debug containers in <regex> 2021-08-09 20:46:56 +01:00
scoped_allocator libstdc++: Improve Doxygen documentation groups [PR 101258] 2021-07-01 00:25:46 +01:00
semaphore libstdc++: Remove #error from <semaphore> implementation [PR 100179] 2021-04-22 13:59:32 +01:00
set libstdc++: Restore debug checks in uniform container erasure functions 2021-10-08 12:20:25 +01:00
shared_mutex libstdc++: Move C++14 <chrono> components to new <bits/chrono.h> header 2021-10-07 21:12:32 +01:00
source_location Update copyright years. 2021-01-04 10:26:59 +01:00
span libstdc++: Add missing constraint to std::span deduction guide [PR102280] 2021-09-16 22:59:47 +01:00
sstream Update copyright years. 2021-01-04 10:26:59 +01:00
stack Update copyright years. 2021-01-04 10:26:59 +01:00
stdexcept libstdc++: Fix doxygen markup for group close commands 2021-04-06 16:43:24 +01:00
stop_token libstdc++: Remove TODO comment 2021-05-10 21:10:34 +01:00
streambuf libstdc++: Fix doxygen markup for group close commands 2021-04-06 16:43:24 +01:00
string libstdc++: Always define typedefs and hash functions for wide strings [PR 98725] 2021-10-09 00:57:49 +01:00
string_view libstdc++: Always define typedefs and hash functions for wide strings [PR 98725] 2021-10-09 00:57:49 +01:00
syncstream libstdc++: Remove noexcept from syncbuf::swap (LWG 3498) 2021-06-25 18:41:30 +01:00
system_error libstdc++: Improvements to Doxygen markup 2021-07-01 18:45:48 +01:00
thread libstdc++: Make std::jthread support pointers to member functions [PR 100612] 2021-10-01 20:36:55 +01:00
tuple libstdc++: Fix move construction of std::tuple with array elements [PR101960] 2021-10-12 16:05:15 +01:00
type_traits libstdc++: Enable type traits for wchar_t unconditionally [PR98725] 2021-10-09 00:57:49 +01:00
typeindex Update copyright years. 2021-01-04 10:26:59 +01:00
unordered_map libstdc++: Restore debug checks in uniform container erasure functions 2021-10-08 12:20:25 +01:00
unordered_set libstdc++: Restore debug checks in uniform container erasure functions 2021-10-08 12:20:25 +01:00
utility libstdc++: Add conditional noexcept to std::exchange 2021-08-17 14:22:49 +01:00
valarray libstdc++: Fix non-reserved names in <valarray> 2021-08-25 22:29:26 +01:00
variant libstdc++: Remove try/catch overhead in std::variant::emplace 2021-10-15 18:26:53 +01:00
vector libstdc++: Restore debug checks in uniform container erasure functions 2021-10-08 12:20:25 +01:00
version libstdc++: Add missing constexpr to std::optional (P2231R1) 2021-10-14 09:08:01 +01:00