gcc/libstdc++-v3/testsuite/ext
Jonathan Wakely b1983f4582 libstdc++: Avoid errors in allocator's noexcept-specifier (PR 89510)
This fixes a regression due to the conditional noexcept-specifier on
std::allocator::construct and std::allocator::destroy, as well as the
corresponding members of new_allocator, malloc_allocator, and
allocator_traits. Those noexcept-specifiers were using expressions which
might be ill-formed, which caused errors outside the immediate context
when checking for the presence of construct and destroy in SFINAE
contexts.

The fix is to use the is_nothrow_constructible and
is_nothrow_destructible type traits instead, because those traits are
safe to use even when the construction/destruction itself is not valid.

The is_nothrow_constructible trait will be false for a type that is not
also nothrow-destructible, even if the new-expression used in the
construct function body is actually noexcept. That's not the correct
answer, but isn't a problem because providing a noexcept-specifier on
these functions is not required by the standard anyway. If the answer is
false when it should be true, that's suboptimal but OK (unlike giving
errors for valid code, or giving a true answer when it should be false).

	PR libstdc++/89510
	* include/bits/alloc_traits.h (allocator_traits::_S_construct)
	(allocator_traits::_S_destroy)
	(allocator_traits<allocator<T>>::construct): Use traits in
	noexcept-specifiers.
	* include/bits/allocator.h (allocator<void>::construct)
	(allocator<void>::destroy): Likewise.
	* include/ext/malloc_allocator.h (malloc_allocator::construct)
	(malloc_allocator::destroy): Likewise.
	* include/ext/new_allocator.h (new_allocator::construct)
	(new_allocator::destroy): Likewise.
	* testsuite/20_util/allocator/89510.cc: New test.
	* testsuite/ext/malloc_allocator/89510.cc: New test.
	* testsuite/ext/new_allocator/89510.cc: New test.
2020-04-30 16:01:43 +01:00
..
bitmap_allocator Update copyright years. 2020-01-01 12:51:42 +01:00
char8_t Fix tests that fail with -std=gnu++98 or -std=gnu++11 2019-06-06 13:13:42 +01:00
codecvt Update copyright years. 2020-01-01 12:51:42 +01:00
concurrence_lock_error Update copyright years. 2020-01-01 12:51:42 +01:00
concurrence_unlock_error Update copyright years. 2020-01-01 12:51:42 +01:00
debug_allocator Update copyright years. 2020-01-01 12:51:42 +01:00
enc_filebuf Update copyright years. 2020-01-01 12:51:42 +01:00
ext_pointer Update copyright years. 2020-01-01 12:51:42 +01:00
forced_error Update copyright years. 2020-01-01 12:51:42 +01:00
iota Update copyright years. 2020-01-01 12:51:42 +01:00
is_heap Update copyright years. 2020-01-01 12:51:42 +01:00
is_sorted Update copyright years. 2020-01-01 12:51:42 +01:00
malloc_allocator libstdc++: Avoid errors in allocator's noexcept-specifier (PR 89510) 2020-04-30 16:01:43 +01:00
mt_allocator Update copyright years. 2020-01-01 12:51:42 +01:00
new_allocator libstdc++: Avoid errors in allocator's noexcept-specifier (PR 89510) 2020-04-30 16:01:43 +01:00
numeric_traits Update copyright years. 2020-01-01 12:51:42 +01:00
pb_ds Update copyright years. 2020-01-01 12:51:42 +01:00
pool_allocator Update copyright years. 2020-01-01 12:51:42 +01:00
random Update copyright years. 2020-01-01 12:51:42 +01:00
rope Update copyright years. 2020-01-01 12:51:42 +01:00
shared_ptr Update copyright years. 2020-01-01 12:51:42 +01:00
slist Update copyright years. 2020-01-01 12:51:42 +01:00
special_functions Update copyright years. 2020-01-01 12:51:42 +01:00
stdio_filebuf Update copyright years. 2020-01-01 12:51:42 +01:00
stdio_sync_filebuf Update copyright years. 2020-01-01 12:51:42 +01:00
throw_allocator Update copyright years. 2020-01-01 12:51:42 +01:00
throw_value Update copyright years. 2020-01-01 12:51:42 +01:00
type_traits Update copyright years. 2020-01-01 12:51:42 +01:00
vstring Update copyright years. 2020-01-01 12:51:42 +01:00
concept_checks.cc Update copyright years. 2020-01-01 12:51:42 +01:00
headers.cc Update copyright years. 2020-01-01 12:51:42 +01:00
median.cc Update copyright years. 2020-01-01 12:51:42 +01:00
pod_char_traits.cc Update copyright years. 2020-01-01 12:51:42 +01:00