Skip to content

Commit 964a404

Browse files
authored
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
1 parent b43a7ac commit 964a404

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

Zend/zend_portability.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,10 @@
109109
# define ZEND_ASSERT(c) ZEND_ASSUME(c)
110110
#endif
111111

112-
#ifdef PHP_HAVE_BUILTIN_UNREACHABLE
112+
/* use C23 unreachable() from <stddef.h> if possible */
113+
#ifdef unreachable
114+
# define _ZEND_UNREACHABLE() unreachable()
115+
#elif defined(PHP_HAVE_BUILTIN_UNREACHABLE)
113116
# define _ZEND_UNREACHABLE() __builtin_unreachable()
114117
#else
115118
# define _ZEND_UNREACHABLE() ZEND_ASSUME(0)

0 commit comments

Comments
 (0)