[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
Wed Feb 9 14:49:08 PST 2022
ldionne added a comment.
In D119152#3309167 <https://reviews.llvm.org/D119152#3309167>, @Quuxplusone wrote:
> I don't think that's guaranteed. `__builtin_unreachable()` just means "assume false"; it doesn't necessarily translate into a `ud2` AFAIK, especially if we're talking about something that will work on both GCC and Clang.
> Even on Clang at `-O0`, it seems to just flow off the unreachable end of `main` into whatever code follows that in memory: https://godbolt.org/z/fz6hh76P5
Oh right, that's why I was seeing invalid instruction. For some reason I thought Clang was inserting something like a `__builtin_trap()`. I stand corrected.
> However, I think we //could// do a `verify.cpp` test: namely,
>
> [[noreturn]] void f() { std::unreachable(); }
>
> should //not// trigger Clang's diagnostic `warning: function declared 'noreturn' should not return [-Winvalid-noreturn]`. If it does, that's a bug.
Yeah, I think that's the best we can do. At least we'll test that `unreachable()` is marked as `[[noreturn]]`.
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