Commit 68a10628a2d for php.net
commit 68a10628a2d6ed7d58bbe4e6dd670bee5c348233
Author: Arnaud Le Blanc <365207+arnaud-lb@users.noreply.github.com>
Date: Thu Feb 5 14:30:58 2026 +0100
Fix -Wdefault-const-init-field-unsafe with clang 21 (#21135)
Fixes the following warning:
Zend/zend_alloc.c:3469:18: error: default initialization of an object of type 'zend_mm_storage' (aka 'struct _zend_mm_storage') with const member leaves the object uninitialized [-Werror,-Wdefault-const-init-field-unsafe]
3469 | zend_mm_storage tmp_storage, *storage;
| ^
Zend/zend_alloc.h:313:25: note: member 'handlers' declared 'const' here
313 | const zend_mm_handlers handlers;
| ^
diff --git a/Zend/zend_alloc.c b/Zend/zend_alloc.c
index ffb4d69066b..bca2190976c 100644
--- a/Zend/zend_alloc.c
+++ b/Zend/zend_alloc.c
@@ -3465,12 +3465,14 @@ ZEND_API zend_mm_heap *zend_mm_startup(void)
ZEND_API zend_mm_heap *zend_mm_startup_ex(const zend_mm_handlers *handlers, void *data, size_t data_size)
{
#if ZEND_MM_STORAGE
- zend_mm_storage tmp_storage, *storage;
+ zend_mm_storage *storage;
+ zend_mm_storage tmp_storage = {
+ .handlers = *handlers,
+ .data = data,
+ };
zend_mm_chunk *chunk;
zend_mm_heap *heap;
- memcpy((zend_mm_handlers*)&tmp_storage.handlers, handlers, sizeof(zend_mm_handlers));
- tmp_storage.data = data;
chunk = (zend_mm_chunk*)handlers->chunk_alloc(&tmp_storage, ZEND_MM_CHUNK_SIZE, ZEND_MM_CHUNK_SIZE);
if (UNEXPECTED(chunk == NULL)) {
#if ZEND_MM_ERROR