aboutsummaryrefslogtreecommitdiff
path: root/libstdc++-v3/include/std/version
diff options
context:
space:
mode:
authorJonathan Wakely <jwakely@redhat.com>2022-04-01 12:25:02 +0100
committerJonathan Wakely <jwakely@redhat.com>2022-04-01 13:17:18 +0100
commitbabaabbcc8346758be0051b32272da18d54f5eea (patch)
tree1a63a98ad862f3fa05fd8e12882a37795f4db7ce /libstdc++-v3/include/std/version
parent944da70a5d1cdc5bd4327b2d32420f57b6883985 (diff)
downloadgcc-babaabbcc8346758be0051b32272da18d54f5eea.zip
gcc-babaabbcc8346758be0051b32272da18d54f5eea.tar.gz
gcc-babaabbcc8346758be0051b32272da18d54f5eea.tar.bz2
libstdc++: Implement std::unreachable() for C++23 (P0627R6)
This defines std::unreachable as an assertion for debug mode, a trap when _GLIBCXX_ASSERTIONS is defined, and __builtin_unreachable() otherwise. The reason for only using __builtin_trap() in the second case is to avoid the overhead of setting up a call to __glibcxx_assert_fail that should never happen. UBsan can detect if __builtin_unreachable() is executed, so if a feature test macro for that sanitizer is added, we could change just use __builtin_unreachable() when the sanitizer is enabled. While thinking about what the debug assertion failure should print, I noticed that the __glibcxx_assert_fail function doesn't check for null pointers. This adds a check so we don't try to print them if null. libstdc++-v3/ChangeLog: * include/std/utility (unreachable): Define for C++23. * include/std/version (__cpp_lib_unreachable): Define. * src/c++11/debug.cc (__glibcxx_assert_fail): Check for valid arguments. Handle only the function being given. * testsuite/20_util/unreachable/1.cc: New test. * testsuite/20_util/unreachable/version.cc: New test.
Diffstat (limited to 'libstdc++-v3/include/std/version')
-rw-r--r--libstdc++-v3/include/std/version1
1 files changed, 1 insertions, 0 deletions
diff --git a/libstdc++-v3/include/std/version b/libstdc++-v3/include/std/version
index 44b8a9f..51f2110 100644
--- a/libstdc++-v3/include/std/version
+++ b/libstdc++-v3/include/std/version
@@ -326,6 +326,7 @@
# define __cpp_lib_string_resize_and_overwrite 202110L
#endif
#define __cpp_lib_to_underlying 202102L
+#define __cpp_lib_unreachable 202202L
#endif
#endif // C++2b
#endif // C++20