[php-src] Issue #7904: FFI::cast() from pointer returns new value instead of reference.

From: Date: Tue, 11 Jan 2022 16:17:29 +0000
Subject: [php-src] Issue #7904: FFI::cast() from pointer returns new value instead of reference.
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-238969@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/7904 Comment Author: cmb69 The first cast in the given script is from char[8] to int32_t which is guaranteed to be valid (i.e. could not possibly work on unallocated memory). The second cast is from char* to int32_t so could possibly manipulate unallocated memory (there is no guarantee that the pointer points to allocated memory). Since #7867 has been fixed, you could work around: ````php $secondInt = FFI::cast('int32_t', FFI::cast('char[4]', $val + 4)); ```` what has the desired effect. So I tend to agree that the current behavior is a bug, or at least the behavior is not desireable.

« previous php.bugs (#238969) next »