[libcxx-commits] [PATCH] D147860: [libcxxabi] [test] Mark code following an assert(false) as unreachable
Petr Hosek via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Sat Apr 8 14:17:52 PDT 2023
phosek added inline comments.
================
Comment at: libcxxabi/test/cxa_vec_new_overflow_PR41395.pass.cpp:18-19
void dummy_ctor(void*) { assert(false && "should not be called"); }
void dummy_dtor(void*) { assert(false && "should not be called"); }
----------------
Should we make the same change to all other `dummy` functions for consistency?
================
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"); }
----------------
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.
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