Skip to content

Fix FFI Parsing of Pointer Declaration Lists - #17794

Merged
dstogov merged 2 commits into
php:PHP-8.3from
davnotdev:PHP-8.3
Feb 17, 2025
Merged

dstogov merged 2 commits into
php:PHP-8.3from
davnotdev:PHP-8.3

Conversation

@davnotdev

Copy link
Copy Markdown
Contributor
struct MyStruct {
    uint8_t** a, *b, c;
};

When a struct is defined in this form, the "base type" of a, b, and c is uint8_t**, so a will be uint8_t**, b will be uint8_t***, and c will be uint8_t**. This PR fixes the issue and adds a test case for it.

@bwoebi

bwoebi commented Feb 14, 2025 •

Copy link
Copy Markdown
Member

This file is generated from ext/ffi/ffi.g, so you should fix that one too.

But thanks for fixing and the test!

@dstogov dstogov left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@davnotdev thanks for catching and fixing this.
@bwoebi thank you for the grammar correction.

@dstogov
dstogov merged commit 52c91f0 into php:PHP-8.3 Feb 17, 2025
dstogov added a commit that referenced this pull request Feb 17, 2025
* PHP-8.3:
  Fix FFI Parsing of Pointer Declaration Lists (#17794)
dstogov added a commit that referenced this pull request Feb 17, 2025
* PHP-8.4:
  Fix FFI Parsing of Pointer Declaration Lists (#17794)
@dstogov

dstogov commented Feb 17, 2025

Copy link
Copy Markdown
Member

The test case might be simplified, but the existing one is also good enough.

$ffi = FFI::cdef(<<<EOF
    struct MyStruct {
        uint8_t** a, *b, c;
    };
EOF);
$x = $ffi->new("struct MyStruct");
var_dump(FFI::typeof($x->a));
var_dump(FFI::typeof($x->b));
var_dump(FFI::typeof($x->c));

ndossche added a commit that referenced this pull request Feb 17, 2025
[ci skip]
ndossche added a commit that referenced this pull request Feb 17, 2025
ndossche added a commit that referenced this pull request Feb 17, 2025
* PHP-8.4:
  NEWS for GH-17794
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants