Use C23 unreachable() when possible (#19077)

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
This commit is contained in:
Calvin Buckley 2025-07-09 11:27:25 -03:00 committed by GitHub
parent b43a7ac0e7
commit 964a404451
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -109,7 +109,10 @@
# define ZEND_ASSERT(c) ZEND_ASSUME(c)
#endif
#ifdef PHP_HAVE_BUILTIN_UNREACHABLE
/* use C23 unreachable() from <stddef.h> 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)