From c62b3698970d6a252bd8eb838c5a23870d4de729 Mon Sep 17 00:00:00 2001 From: Calvin Buckley Date: Wed, 9 Jul 2025 00:12:19 -0300 Subject: [PATCH] Use C23 unreachable() when possible This is a macro defined in stddef, which is already included in this header. Since this is a macro, we can just check for the define rather than add any additional build system checks. Fixes GH-18975 --- Zend/zend_portability.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Zend/zend_portability.h b/Zend/zend_portability.h index 7a41a496a0ed7..1b28f21c39a87 100644 --- a/Zend/zend_portability.h +++ b/Zend/zend_portability.h @@ -109,7 +109,10 @@ # define ZEND_ASSERT(c) ZEND_ASSUME(c) #endif -#ifdef PHP_HAVE_BUILTIN_UNREACHABLE +/* use C23 unreachable() from if possible */ +#ifdef unreachable +# define _ZEND_UNREACHABLE() unreachable() +#elif defined(PHP_HAVE_BUILTIN_UNREACHABLE) # define _ZEND_UNREACHABLE() __builtin_unreachable() #else # define _ZEND_UNREACHABLE() ZEND_ASSUME(0)