From 04dda23d1842ba24006dd87346fd28777706af6a Mon Sep 17 00:00:00 2001 From: lazerg Date: Thu, 29 Oct 2026 06:23:55 +0500 Subject: [PATCH 1/3] Fix GH-25023: ZEND_CONTAINER_OF() fails to compile with -std=c11 --- Zend/zend_portability.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Zend/zend_portability.h b/Zend/zend_portability.h index ccad24682fdb..1df53ad1125e 100644 --- a/Zend/zend_portability.h +++ b/Zend/zend_portability.h @@ -406,8 +406,8 @@ extern "C++" { # define ZEND_CONTAINER_OF(ptr, Type, member) \ _Generic( \ (ptr), \ - const typeof(((Type*)0)->member) *: ((const Type*)((char*)(ptr) - offsetof(Type, member))), \ - typeof(((Type*)0)->member) *: ((Type*)((char*)(ptr) - offsetof(Type, member))) \ + const __typeof__(((Type*)0)->member) *: ((const Type*)((char*)(ptr) - offsetof(Type, member))), \ + __typeof__(((Type*)0)->member) *: ((Type*)((char*)(ptr) - offsetof(Type, member))) \ ) #else /* Define a variant that does not keep const-ness for older compilers. Mismatches From 804a23081d60bd40c98b5aede3905bd30edca510 Mon Sep 17 00:00:00 2001 From: lazerg Date: Thu, 29 Oct 2026 12:58:17 +0500 Subject: [PATCH 2/3] Add ZEND_TYPEOF() and use it in ZEND_CONTAINER_OF() --- Zend/zend_portability.h | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/Zend/zend_portability.h b/Zend/zend_portability.h index 1df53ad1125e..3549fe6f544b 100644 --- a/Zend/zend_portability.h +++ b/Zend/zend_portability.h @@ -387,6 +387,12 @@ char *alloca(); #define ZEND_ELEMENT_COUNT(m) #endif +#if __STDC_VERSION__ >= 202311L +# define ZEND_TYPEOF(x) typeof(x) +#elif ZEND_GCC_VERSION +# define ZEND_TYPEOF(x) __typeof__(x) +#endif + #if __cplusplus extern "C++" { # include @@ -401,13 +407,12 @@ extern "C++" { # define ZEND_CONTAINER_OF(ptr, Type, member) zend_container_of(ptr, offsetof(Type, member)) } -#elif __STDC_VERSION__ >= 202311L || ZEND_GCC_VERSION -/* typeof is C23 or a GCC extension */ +#elif defined(ZEND_TYPEOF) # define ZEND_CONTAINER_OF(ptr, Type, member) \ _Generic( \ (ptr), \ - const __typeof__(((Type*)0)->member) *: ((const Type*)((char*)(ptr) - offsetof(Type, member))), \ - __typeof__(((Type*)0)->member) *: ((Type*)((char*)(ptr) - offsetof(Type, member))) \ + const ZEND_TYPEOF(((Type*)0)->member) *: ((const Type*)((char*)(ptr) - offsetof(Type, member))), \ + ZEND_TYPEOF(((Type*)0)->member) *: ((Type*)((char*)(ptr) - offsetof(Type, member))) \ ) #else /* Define a variant that does not keep const-ness for older compilers. Mismatches From 62164fb9cd7a5b40324b907af3ff5c76a5e54ec8 Mon Sep 17 00:00:00 2001 From: Arnaud Le Blanc Date: Thu, 29 Oct 2026 10:26:13 +0100 Subject: [PATCH 3/3] [ci skip] NEWS --- NEWS | 2 ++ 1 file changed, 2 insertions(+) diff --git a/NEWS b/NEWS index bf0ae375324f..6899e0b14e81 100644 --- a/NEWS +++ b/NEWS @@ -7,6 +7,8 @@ PHP NEWS for grouping. (Klaas Skelte van der Werf) . Fixed unmapping of an unrelated range when the aligned chunk mmap fails (Marti2203). + . Fixed bug GH-25023 (ZEND_CONTAINER_OF() fails to compile with -std=c11). + (lazerg) - CLI: . Fixed bug GH-24697 (PHP_HTTP_PARSER_STRICT build option doesn't work).