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

Martin Storsjö via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Sat Apr 8 13:10:23 PDT 2023


mstorsjo created this revision.
mstorsjo added reviewers: phosek, alvinhochun.
Herald added a project: All.
mstorsjo requested review of this revision.
Herald added a project: libc++abi.
Herald added a reviewer: libc++abi.

With current versions of mingw-w64 headers, code following
assert(false) isn't considered unreachable - thus mark it
as such with __builtin_unreachable(), to avoid warnings (treated as
errors) for a missing return statement.

The root cause does get fixed further upstream in mingw-w64 in
https://github.com/mingw-w64/mingw-w64/commit/1690994f515910a31b9fb7c7bd3a52d4ba987abe
though.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D147860

Files:
  libcxxabi/test/cxa_vec_new_overflow_PR41395.pass.cpp


Index: libcxxabi/test/cxa_vec_new_overflow_PR41395.pass.cpp
===================================================================
--- libcxxabi/test/cxa_vec_new_overflow_PR41395.pass.cpp
+++ libcxxabi/test/cxa_vec_new_overflow_PR41395.pass.cpp
@@ -18,7 +18,7 @@
 void dummy_ctor(void*) { assert(false && "should not be called"); }
 void dummy_dtor(void*) { assert(false && "should not be called"); }
 
-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"); }
 void dummy_dealloc_sized(void*, size_t) { assert(false && "should not be called"); }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D147860.511925.patch
Type: text/x-patch
Size: 729 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20230408/db240831/attachment.bin>


More information about the libcxx-commits mailing list