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

Nikolas Klauser via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Tue Feb 8 15:06:13 PST 2022


philnik marked 3 inline comments as done.
philnik added a comment.

In D119152#3306155 <https://reviews.llvm.org/D119152#3306155>, @ldionne wrote:

> 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).

How do you expect the libc++-specific test to look? The compiler won't ignore that there is a `__builtin_unreachable` in the way and just remove all the code after that. We don't control the behavior in this case. We don't even have to do anything in `unreachable()`. It can just be empty and marked with `[[noreturn]]` and it would work pretty much the same.  https://godbolt.org/z/GvbnG76nW


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