[libcxx-commits] [PATCH] D147860: [libcxxabi] [test] Mark code following an assert(false) as unreachable

Eric Fiselier via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Mon Apr 10 15:54:53 PDT 2023


EricWF added inline comments.


================
Comment at: libcxxabi/test/cxa_vec_new_overflow_PR41395.pass.cpp:21
 
-void *dummy_alloc(size_t) { assert(false && "should not be called"); }
+void *dummy_alloc(size_t) { assert(false && "should not be called"); __builtin_unreachable(); }
 void dummy_dealloc(void*) { assert(false && "should not be called"); }
----------------
mstorsjo wrote:
> phosek wrote:
> > I wonder if we should instead use `__bultin_trap()` to ensure that the code doesn't continue executing even with assertions disabled? This was also discussed in https://discourse.llvm.org/t/llvm-unreachable-is-widely-misused/60587.
> I guess that's a reasonable fix too, I'll try that.
If the compiler isn't figuring out that it's unreachable, are we sure assertions are enabled?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D147860/new/

https://reviews.llvm.org/D147860



More information about the libcxx-commits mailing list