[libcxx-commits] [PATCH] D119152: [libc++] Implement P0627R6 (Function to mark unreachable code)
Louis Dionne via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Tue Feb 8 14:21:22 PST 2022
ldionne requested changes to this revision.
ldionne added a comment.
This revision now requires changes to proceed.
We should add a test, at least a `.compile.pass.cpp` test that we're defining the function and that it returns `void`. Also:
- We should update the feature-test macro
- We should add a release note for this feature (I want to be aggressive about release-noting the features we implement)
- We should also add a libc++ specific test (should be a `.fail.cpp`) that executes `std::unreachable()`, which would confirm that we somehow stop the execution of the program when encountered. Basically, I'd like a test that fails if `std::unreachable()` were implemented as an empty function. This is libc++ specific since technically, executing it is undefined behavior (but we know what we actually do).
================
Comment at: libcxx/include/__utility/unreachable.h:18
+{
+#ifdef __GNUC__
+ __builtin_unreachable();
----------------
I believe we should use `__has_builtin(__builtin_unreachable)` here instead -- that would avoid hardcoding compiler knowledge.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D119152/new/
https://reviews.llvm.org/D119152
More information about the libcxx-commits
mailing list