From 35f1adb99a2b13ed8359ee7c223f47c7a8860456 Mon Sep 17 00:00:00 2001 From: Khaled Alam Date: Tue, 20 Jan 2026 16:10:16 +0400 Subject: [PATCH 1/2] feat: Remove unreachable code after zend_error_noreturn calls. --- Zend/zend_compile.c | 4 ---- Zend/zend_inheritance.c | 3 --- 2 files changed, 7 deletions(-) diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index 5eba2ec1366fa..3547b3d863575 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -2646,7 +2646,6 @@ static void zend_emit_return_type_check( ZEND_ASSERT(!implicit); zend_error_noreturn(E_COMPILE_ERROR, "A never-returning %s must not return", CG(active_class_entry) != NULL ? "method" : "function"); - return; } if (!expr && !implicit) { @@ -7480,14 +7479,12 @@ static zend_type zend_compile_typename_ex( zend_string *standard_type_str = zend_type_to_string(single_type); zend_error_noreturn(E_COMPILE_ERROR, "Type %s cannot be part of an intersection type", ZSTR_VAL(standard_type_str)); - zend_string_release_ex(standard_type_str, false); } /* An intersection of standard types cannot exist so invalidate it */ if (ZEND_TYPE_IS_ONLY_MASK(single_type)) { zend_string *standard_type_str = zend_type_to_string(single_type); zend_error_noreturn(E_COMPILE_ERROR, "Type %s cannot be part of an intersection type", ZSTR_VAL(standard_type_str)); - zend_string_release_ex(standard_type_str, false); } /* Check for "self" and "parent" too */ if ( @@ -7720,7 +7717,6 @@ static void zend_compile_attributes( if (error != NULL) { if (delayed_target_validation == NULL) { zend_error_noreturn(E_COMPILE_ERROR, "%s", ZSTR_VAL(error)); - zend_string_efree(error); } else { attr->validation_error = error; } diff --git a/Zend/zend_inheritance.c b/Zend/zend_inheritance.c index 3c3931cdca164..40953732359cf 100644 --- a/Zend/zend_inheritance.c +++ b/Zend/zend_inheritance.c @@ -2274,7 +2274,6 @@ static void zend_do_implement_interfaces(zend_class_entry *ce, zend_class_entry zend_get_object_type_uc(ce), ZSTR_VAL(ce->name), ZSTR_VAL(iface->name)); - return; } /* skip duplications */ ZEND_HASH_MAP_FOREACH_STR_KEY_PTR(&iface->constants_table, key, c) { @@ -2525,7 +2524,6 @@ static uint32_t zend_check_trait_usage(const zend_class_entry *ce, const zend_cl { if (UNEXPECTED((trait->ce_flags & ZEND_ACC_TRAIT) != ZEND_ACC_TRAIT)) { zend_error_noreturn(E_COMPILE_ERROR, "Class %s is not a trait, Only traits may be used in 'as' and 'insteadof' statements", ZSTR_VAL(trait->name)); - return 0; } for (uint32_t i = 0; i < ce->num_traits; i++) { @@ -2534,7 +2532,6 @@ static uint32_t zend_check_trait_usage(const zend_class_entry *ce, const zend_cl } } zend_error_noreturn(E_COMPILE_ERROR, "Required Trait %s wasn't added to %s", ZSTR_VAL(trait->name), ZSTR_VAL(ce->name)); - return 0; } /* }}} */ From 270c8945e638c5d4fa862a38913330f42a9bc5fb Mon Sep 17 00:00:00 2001 From: Khaled Alam Date: Tue, 20 Jan 2026 16:20:04 +0400 Subject: [PATCH 2/2] feat: remove more of dead code. --- Zend/zend_alloc.c | 1 - Zend/zend_compile.c | 1 - Zend/zend_execute_API.c | 3 --- 3 files changed, 5 deletions(-) diff --git a/Zend/zend_alloc.c b/Zend/zend_alloc.c index 1157dc98fa615..ffb4d69066b97 100644 --- a/Zend/zend_alloc.c +++ b/Zend/zend_alloc.c @@ -1480,7 +1480,6 @@ static zend_always_inline void *zend_mm_alloc_heap(zend_mm_heap *heap, size_t si size = ZEND_MM_ALIGNED_SIZE(size) + ZEND_MM_ALIGNED_SIZE(sizeof(zend_mm_debug_info)); if (UNEXPECTED(size < real_size)) { zend_error_noreturn(E_ERROR, "Possible integer overflow in memory allocation (%zu + %zu)", ZEND_MM_ALIGNED_SIZE(real_size), ZEND_MM_ALIGNED_SIZE(sizeof(zend_mm_debug_info))); - return NULL; } #endif if (EXPECTED(size <= ZEND_MM_MAX_SMALL_SIZE)) { diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index 3547b3d863575..0d275a305e05d 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -11485,7 +11485,6 @@ static void zend_compile_const_expr_class_name(zend_ast **ast_ptr) /* {{{ */ case ZEND_FETCH_CLASS_STATIC: zend_error_noreturn(E_COMPILE_ERROR, "static::class cannot be used for compile-time class name resolution"); - return; EMPTY_SWITCH_DEFAULT_CASE() } } diff --git a/Zend/zend_execute_API.c b/Zend/zend_execute_API.c index e134d3d496b6d..d3f03d1fe6dfb 100644 --- a/Zend/zend_execute_API.c +++ b/Zend/zend_execute_API.c @@ -1565,7 +1565,6 @@ static void zend_set_timeout_ex(zend_long seconds, bool reset_signals) /* {{{ */ if (!DeleteTimerQueueTimer(NULL, tq_timer, INVALID_HANDLE_VALUE)) { tq_timer = NULL; zend_error_noreturn(E_ERROR, "Could not delete queued timer"); - return; } tq_timer = NULL; } @@ -1575,7 +1574,6 @@ static void zend_set_timeout_ex(zend_long seconds, bool reset_signals) /* {{{ */ if (!CreateTimerQueueTimer(&tq_timer, NULL, (WAITORTIMERCALLBACK)tq_timer_cb, (VOID*)eg, seconds*1000, 0, WT_EXECUTEONLYONCE)) { tq_timer = NULL; zend_error_noreturn(E_ERROR, "Could not queue new timer"); - return; } #elif defined(ZEND_MAX_EXECUTION_TIMERS) if (seconds > 0) { @@ -1662,7 +1660,6 @@ void zend_unset_timeout(void) /* {{{ */ zend_atomic_bool_store_ex(&EG(timed_out), false); tq_timer = NULL; zend_error_noreturn(E_ERROR, "Could not delete queued timer"); - return; } tq_timer = NULL; }