[php-src] PHP-8.5: Fix -Wint-to-pointer-cast warnings in the CALL VM on 32-bit (#24360)

From: Date: Mon, 19 Oct 2026 09:43:07 +0000
Subject: [php-src] PHP-8.5: Fix -Wint-to-pointer-cast warnings in the CALL VM on 32-bit (#24360)
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-142428@lists.php.net to get a copy of this message
Author: Marc Bennewitz (marc-mabe) Committer: GitHub (web-flow) Pusher: arnaud-lb Date: 2026-10-19T11:43:04+02:00 Commit: https://github.com/php/php-src/commit/4bb88e0367fe6d074e15d0bec13217d51b815dca Raw diff: https://github.com/php/php-src/commit/4bb88e0367fe6d074e15d0bec13217d51b815dca.diff Fix -Wint-to-pointer-cast warnings in the CALL VM on 32-bit (#24360) ZEND_VM_ENTER_BIT tags the opline returned by CALL VM handlers. It is 1ULL so that ~ZEND_VM_ENTER_BIT keeps the upper half of 64-bit pointers, but on 32-bit platforms it widens the tagged pointer expressions to 64 bits, and casting those back to a pointer warns. This breaks --enable-werror builds where no global VM registers are used, e.g. arm32, or i386 with --disable-gcc-global-regs. Use (uintptr_t)1 instead, which is exactly pointer-sized everywhere, also in the copies of the definition in the JIT and the fuzzer SAPI. Changed paths: M Zend/zend_vm_execute.h M Zend/zend_vm_gen.php M ext/opcache/jit/zend_jit_internal.h M sapi/fuzzer/fuzzer-execute-common.h Diff: diff --git a/Zend/zend_vm_execute.h b/Zend/zend_vm_execute.h index 2b5d042666c4..2bc51f2841a2 100644 --- a/Zend/zend_vm_execute.h +++ b/Zend/zend_vm_execute.h @@ -440,7 +440,7 @@ static zend_vm_opcode_handler_func_t zend_vm_get_opcode_handler_func(uint8_t opc # define ZEND_VM_ENTER() opline = EG(current_execute_data)->opline; ZEND_VM_ENTER_EX() # define ZEND_VM_LEAVE() return 2 #else -# define ZEND_VM_ENTER_BIT 1ULL +# define ZEND_VM_ENTER_BIT ((uintptr_t)1) # define ZEND_VM_ENTER_EX() return (zend_op*)((uintptr_t)opline | ZEND_VM_ENTER_BIT) # define ZEND_VM_ENTER() execute_data = EG(current_execute_data); LOAD_OPLINE(); ZEND_VM_ENTER_EX() # define ZEND_VM_LEAVE() return (zend_op*)((uintptr_t)opline | ZEND_VM_ENTER_BIT) diff --git a/Zend/zend_vm_gen.php b/Zend/zend_vm_gen.php index e08d9ebd32b2..0b9c47a330ef 100755 --- a/Zend/zend_vm_gen.php +++ b/Zend/zend_vm_gen.php @@ -2040,7 +2040,7 @@ function gen_executor($f, $skl, $spec, $kind, $executor_name, $initializer_name) out($f,"# define ZEND_VM_ENTER() opline = EG(current_execute_data)->opline; ZEND_VM_ENTER_EX()\n"); out($f,"# define ZEND_VM_LEAVE() return 2\n"); out($f,"#else\n"); - out($f,"# define ZEND_VM_ENTER_BIT 1ULL\n"); + out($f,"# define ZEND_VM_ENTER_BIT ((uintptr_t)1)\n"); out($f,"# define ZEND_VM_ENTER_EX() return (zend_op*)((uintptr_t)opline | ZEND_VM_ENTER_BIT)\n"); out($f,"# define ZEND_VM_ENTER() execute_data = EG(current_execute_data); LOAD_OPLINE(); ZEND_VM_ENTER_EX()\n"); out($f,"# define ZEND_VM_LEAVE() return (zend_op*)((uintptr_t)opline | ZEND_VM_ENTER_BIT)\n"); diff --git a/ext/opcache/jit/zend_jit_internal.h b/ext/opcache/jit/zend_jit_internal.h index 8732b424f00a..bcc267a4000e 100644 --- a/ext/opcache/jit/zend_jit_internal.h +++ b/ext/opcache/jit/zend_jit_internal.h @@ -224,7 +224,7 @@ extern const zend_op *zend_jit_interrupt_op; # define ZEND_OPCODE_HANDLER_ARGS_PASSTHRU EXECUTE_DATA_C OPLINE_CC # define ZEND_OPCODE_HANDLER_ARGS_EX EXECUTE_DATA_D OPLINE_DC, # define ZEND_OPCODE_HANDLER_ARGS_PASSTHRU_EX EXECUTE_DATA_C OPLINE_CC, -# define ZEND_VM_ENTER_BIT 1ULL +# define ZEND_VM_ENTER_BIT ((uintptr_t)1) #endif /* VM helpers */ diff --git a/sapi/fuzzer/fuzzer-execute-common.h b/sapi/fuzzer/fuzzer-execute-common.h index 338c771e551a..9758fe7a628b 100644 --- a/sapi/fuzzer/fuzzer-execute-common.h +++ b/sapi/fuzzer/fuzzer-execute-common.h @@ -28,7 +28,7 @@ #define FILE_NAME "/tmp/fuzzer.php" #define MAX_STEPS 1000 #define MAX_SIZE (8 * 1024) -#define ZEND_VM_ENTER_BIT 1ULL +#define ZEND_VM_ENTER_BIT ((uintptr_t)1) static uint32_t steps_left; static bool bailed_out = false;

« previous php.cvs (#142428) next »