[libcxx-commits] [PATCH] D119152: [libc++] Implement P0627R6 (Function to mark unreachable code)

Arthur O'Dwyer via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Mon Feb 7 13:32:45 PST 2022


Quuxplusone requested changes to this revision.
Quuxplusone added a subscriber: mstorsjo.
Quuxplusone added inline comments.
This revision now requires changes to proceed.


================
Comment at: libcxx/include/__utility/unreachable.h:18
+
+[[noreturn]] _LIBCPP_HIDE_FROM_ABI inline void unreachable() { __builtin_unreachable(); }
+
----------------
@ldionne @mstorsjo perhaps: What's the best way to get this to do `__assume(false)` on MSVC? Should we introduce a `__libcpp_unreachable()`?... Oh wait, we already have one. In `libcxx/include/cstdlib` we have:
```
#ifdef __GNUC__
#define _LIBCPP_UNREACHABLE() __builtin_unreachable()
#else
#define _LIBCPP_UNREACHABLE() _VSTD::abort()
#endif
```
Let's do something in this PR to normalize the situation. Perhaps involving `__has_builtin`, perhaps involving `defined(_MSC_VER)`, but the end result should be that libc++'s `std::unreachable` is implemented in terms of `_LIBCPP_UNREACHABLE`.


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