[php-src] Issue #8007: FFI::cast() from pointer returns incorrect value

From: Date: Sat, 29 Jan 2022 02:45:53 +0000
Subject: [php-src] Issue #8007: FFI::cast() from pointer returns incorrect value
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-239340@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/8007 Comment Author: damianwadley Two issues here. First is that you're using N in the pack, which is big-endian and unsigned, but int32_t will be machine-dependent order and signed. If I change your pack() to use l then I get the expected output for "first". The second is that char[] + 4 will give you a pointer, and if you cast the pointer to a int32_t then you'll get a number for the memory address. You need to work with them as pointers, meaning cast to a int32_t* and then dereference that. However casting the original _array_ to an int32_t works.

« previous php.bugs (#239340) next »