[php-src] Issue #14776: PHP 8.3.8: ffi struct bit-fields value is not accepted.

From: Date: Wed, 03 Jul 2024 04:02:06 +0000
Subject: [php-src] Issue #14776: PHP 8.3.8: ffi struct bit-fields value is not accepted.
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-247212@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/14776 Author: klusfq ### Description The following code: ```c // some.h typedef enum PLDB_VALUE_TYPE { PLDB_VAL_NULL = 0x0A, PLDB_VAL_DOUBL = 0x01, PLDB_VAL_BOOLEAN = 0x08, PLDB_VAL_INT = 0x16, PLDB_VAL_STRING = 0x02, PLDB_VAL_OBJECT_ID = 0x07, PLDB_VAL_ARRAY = 0x17, PLDB_VAL_DOCUMENT = 0x13, PLDB_VAL_BINARY = 0x05, PLDB_VAL_UTC_DATETIME = 0x09, } PLDB_VALUE_TYPE; typedef struct PLDBValue { PLDB_VALUE_TYPE tag: 8; union { int64_t int_value; double double_value; int bool_value; const char* str; DbObjectId* oid; DbArray* arr; DbDocument* doc; uint64_t utc; } v; } PLDBValue; void print_byte_stream(PLDBValue value); ``` ```php // main.php <?php $ffi = \FFI::load('some.h'); $data = $ffi->new('PLDBValue'); $data->tag = FFI\Scalar\Type::uint8(0x16)->cdata; $data->v->int_value = FFI\Scalar\Type::int64(18); $ffi->print_byte_stream($data); ``` Resulted in this output: ``` Bytes: 0x12 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x1 0x0 0x0 0x0 0x32 0x30 0x31 0x36 ``` But I expected this output instead: ``` Bytes: 0x16 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x12 0x0 0x0 0x0 0x0 0x0 0x0 0x0 ``` When I modify PLDB_VALUE_TYPE tag: 8; to uint8_t tag;, I will get my expected output. ### PHP Version PHP 8.3.8 ### Operating System Ubuntu 22.04

« previous php.bugs (#247212) next »