[PATCH] 1/2 Make _GLIBCXX_DEBUG checks constexpr compatible

François Dumont frs.dumont@gmail.com
Sun Nov 8 14:06:06 GMT 2020


Now that __glibcxx_assert is constexpr compatible we can do the same for 
the _GLIBCXX_DEBUG equivalent.

I had also try to do the same on my own so this patch contains the 
string_view tests I had written when doing so.

I plan to activate some _GLIBCXX_DEBUG checks when _GLIBCXX_ASSERTIONS 
is defined but only the contant time checks. Is it ok to run checks like 
__check_partitioned_lower in constexpr ?

     libstdc++: Make _GLIBCXX_DEBUG checks constexpr compatible

     libstdc++-v3/ChangeLog:

             * include/debug/assertions.h 
(__glibcxx_requires_non_empty_range):
             Remove __builtin_expect.
             (__glibcxx_requires_subscript): Likewise.
             (__glibcxx_requires_nonempty): Likewise.
             * include/debug/formatter.h (__check_singular): Add C++11 
constexpr
             qualification.
             * include/debug/helper_functions.h (__check_singular): 
Likewise. Skip
             check if constant evaluated.
             (__valid_range): Do not skip check if constant evaluated.
             * include/debug/macros.h (_GLIBCXX_DEBUG_VERIFY_COND_AT): Add
             __builtin_expect.
             (_GLIBCXX_DEBUG_VERIFY_AT_F): Use __glibcxx_assert_1.
             * testsuite/21_strings/basic_string_view/element_access/char/
             back_constexpr_neg.cc: New test.
             * testsuite/21_strings/basic_string_view/element_access/char/
             constexpr.cc: New test.
             * testsuite/21_strings/basic_string_view/element_access/char/
             constexpr_neg.cc: New test.
             * testsuite/21_strings/basic_string_view/element_access/char/
             front_back_constexpr.cc: New test.
             * testsuite/21_strings/basic_string_view/element_access/char/
             front_constexpr_neg.cc: New test.
             * 
testsuite/21_strings/basic_string_view/element_access/wchar_t/
             back_constexpr_neg.cc: New test.
             * 
testsuite/21_strings/basic_string_view/element_access/wchar_t/
             constexpr.cc: New test.
             * 
testsuite/21_strings/basic_string_view/element_access/wchar_t/
             constexpr_neg.cc: New test.
             * 
testsuite/21_strings/basic_string_view/element_access/wchar_t/
             front_constexpr_neg.cc: New test.
             * testsuite/25_algorithms/lower_bound/debug/
             constexpr_partitioned_neg.cc: New test.
             * testsuite/25_algorithms/lower_bound/debug/
             constexpr_partitioned_pred_neg.cc: New test.
             * testsuite/25_algorithms/lower_bound/debug/
             constexpr_valid_range_neg.cc: New test.
             * testsuite/25_algorithms/lower_bound/debug/partitioned_neg.cc:
             New test.
             * 
testsuite/25_algorithms/lower_bound/debug/partitioned_pred_neg.cc:
             New test.
             * testsuite/25_algorithms/upper_bound/debug/
             constexpr_partitioned_neg.cc: New test.
             * testsuite/25_algorithms/upper_bound/debug/
             constexpr_partitioned_pred_neg.cc: New test.
             * testsuite/25_algorithms/upper_bound/debug/
             constexpr_valid_range_neg.cc: New test.
             * testsuite/25_algorithms/upper_bound/debug/partitioned_neg.cc:
             New test.
             * 
testsuite/25_algorithms/upper_bound/debug/partitioned_pred_neg.cc:
             New test.

Tested under Linux x86_64.

Ok to commit ?

François

-------------- next part --------------
A non-text attachment was scrubbed...
Name: debug_constexpr.patch
Type: text/x-patch
Size: 35048 bytes
Desc: not available
URL: <https://gcc.gnu.org/pipermail/libstdc++/attachments/20201108/1de7ebf1/attachment-0001.bin>


More information about the Libstdc++ mailing list