gcc/libstdc++-v3/include/parallel
Jonathan Wakely 10f51543bb libstdc++: Add compile-time checks to__glibcxx_assert [PR 71960]
This change evaluates __glibcxx_assert checks unconditionally when a
function is being constant evaluated (when std::is_constant_evaluated()
is true). If the check fails, compilation will fail with an error.

If the function isn't being constant evaluated, the normal runtime check
will be done if enabled by _GLIBCXX_ASSERTIONS or _GLIBCXX_DEBUG, the
same as before.

Tangentially, the __glibcxx_assert and _GLIBCXX_PARALLEL_ASSERT macros
are changed to expand to 'do { } while (false)' when assertions are
disabled, instead of expanding to nothing. This avoids -Wempty-body
warnings when a disabled assertion is used in an 'if' or 'else'
statement e.g.

  if constexpr (/* precondition is testable */)
    __glibcxx_assert(precondition);

a.C:9:27: warning: suggest braces around empty body in an ‘if’ statement [-Wempty-body]
    9 |     __glibcxx_assert(precondition);
      |                                  ^

libstdc++-v3/ChangeLog:

	PR libstdc++/71960
	* include/bits/c++config (__glibcxx_assert_impl): Remove
	do-while so that uses of the macro need to add it.
	(__glibcxx_assert): Rename macro for runtime assertions
	to __glibcxx_assert_2.
	(__glibcxx_assert_1): Define macro for constexpr assertions.
	(__glibcxx_assert): Define macro for constexpr and runtime
	assertions.
	* include/bits/range_access.h (ranges::advance): Remove
	redundant precondition checks during constant evaluation.
	* include/parallel/base.h (_GLIBCXX_PARALLEL_ASSERT): Always
	use do-while in macro expansion.
	* include/std/ranges (iota_view::iota_view(W, B)): Remove
	redundant braces.
2020-09-01 20:52:26 +01:00
..
algo.h Update copyright years. 2020-01-01 12:51:42 +01:00
algobase.h libstdc++: Fix some C++20 algorithms to work in parallel mode 2020-05-07 21:43:49 +01:00
algorithm Update copyright years. 2020-01-01 12:51:42 +01:00
algorithmfwd.h Update copyright years. 2020-01-01 12:51:42 +01:00
balanced_quicksort.h Update copyright years. 2020-01-01 12:51:42 +01:00
base.h libstdc++: Add compile-time checks to__glibcxx_assert [PR 71960] 2020-09-01 20:52:26 +01:00
basic_iterator.h Update copyright years. 2020-01-01 12:51:42 +01:00
checkers.h Update copyright years. 2020-01-01 12:51:42 +01:00
compatibility.h Update copyright years. 2020-01-01 12:51:42 +01:00
compiletime_settings.h Update copyright years. 2020-01-01 12:51:42 +01:00
equally_split.h Update copyright years. 2020-01-01 12:51:42 +01:00
features.h Update copyright years. 2020-01-01 12:51:42 +01:00
find_selectors.h Update copyright years. 2020-01-01 12:51:42 +01:00
find.h Update copyright years. 2020-01-01 12:51:42 +01:00
for_each_selectors.h Update copyright years. 2020-01-01 12:51:42 +01:00
for_each.h Update copyright years. 2020-01-01 12:51:42 +01:00
iterator.h Update copyright years. 2020-01-01 12:51:42 +01:00
list_partition.h Update copyright years. 2020-01-01 12:51:42 +01:00
losertree.h Update copyright years. 2020-01-01 12:51:42 +01:00
merge.h Update copyright years. 2020-01-01 12:51:42 +01:00
multiseq_selection.h Update copyright years. 2020-01-01 12:51:42 +01:00
multiway_merge.h libstdc++: Make relational operators work with const guarded iterators (PR 92472) 2020-05-07 21:43:49 +01:00
multiway_mergesort.h Update copyright years. 2020-01-01 12:51:42 +01:00
numeric Update copyright years. 2020-01-01 12:51:42 +01:00
numericfwd.h Update copyright years. 2020-01-01 12:51:42 +01:00
omp_loop_static.h Update copyright years. 2020-01-01 12:51:42 +01:00
omp_loop.h Update copyright years. 2020-01-01 12:51:42 +01:00
par_loop.h Update copyright years. 2020-01-01 12:51:42 +01:00
parallel.h Update copyright years. 2020-01-01 12:51:42 +01:00
partial_sum.h Update copyright years. 2020-01-01 12:51:42 +01:00
partition.h Update copyright years. 2020-01-01 12:51:42 +01:00
queue.h Update copyright years. 2020-01-01 12:51:42 +01:00
quicksort.h Update copyright years. 2020-01-01 12:51:42 +01:00
random_number.h Update copyright years. 2020-01-01 12:51:42 +01:00
random_shuffle.h Update copyright years. 2020-01-01 12:51:42 +01:00
search.h Update copyright years. 2020-01-01 12:51:42 +01:00
set_operations.h Update copyright years. 2020-01-01 12:51:42 +01:00
settings.h Update copyright years. 2020-01-01 12:51:42 +01:00
sort.h Update copyright years. 2020-01-01 12:51:42 +01:00
tags.h Update copyright years. 2020-01-01 12:51:42 +01:00
types.h Update copyright years. 2020-01-01 12:51:42 +01:00
unique_copy.h Update copyright years. 2020-01-01 12:51:42 +01:00
workstealing.h Update copyright years. 2020-01-01 12:51:42 +01:00