php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #78253 Const modifier for undeclared structures hides an original error
Submitted: 2019-07-05 09:18 UTC Modified: 2021-09-15 12:03 UTC
From: lisachenko dot it at gmail dot com Assigned:
Status: Duplicate Package: ffi (PECL)
PHP Version: 7.4.0alpha2 OS: Windows
Private report: No CVE-ID: None
 [2019-07-05 09:18 UTC] lisachenko dot it at gmail dot com
Description:
------------
Following construction with "const" and double pointer modifier could not be parsed by FFI:

    typedef struct _simple_struct {
        const some_not_declared_type **property;
    } simple_struct;

Test script:
---------------
<?php
$ffi = FFI::cdef("
    typedef struct _simple_struct {
        const some_not_declared_type **property;
    } simple_struct;
");

Expected result:
----------------
Fatal error: Uncaught FFI\ParserException: undefined C type 'some_not_declared_type'

Actual result:
--------------
Fatal error: Uncaught FFI\ParserException: unexpected '*' at line

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2019-10-21 13:34 UTC] cmb@php.net
I can confirm this behavior.  It is due to a limitation of parsing C
declarations with an LL(*) parser, namely that for conflict resolution
some symbols have to be known in advance[1].

I suggest to changing to documentation problem.

[1] <https://gist.github.com/rygorous/d905d42489158a5d8b17607887f82de5>
 [2021-09-15 10:31 UTC] dmitry@php.net
-Status: Open +Status: Duplicate
 [2021-09-15 10:31 UTC] dmitry@php.net
the same as Bug #79576
 [2021-09-15 12:03 UTC] dmitry@php.net
Fixed together with #79576
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Dec 13 03:01:28 2024 UTC