|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #77768 FFI: Builtin Types Should Not Raise Error On Redeclaration
Submitted: 2019-03-19 14:30 UTC Modified: 2019-03-24 18:54 UTC
From: Assigned: dmitry (profile)
Status: Closed Package: Unknown/Other Function
PHP Version: Next Minor Version OS:
Private report: No CVE-ID: None
 [2019-03-19 14:30 UTC]
In line with other FFI implementations, defining builtin types such as va_args, __builtin_va_list and __gnuc_va_list should not raise a redefinition error, but should be silently ignored.

For example, LUAJIT's FFI documentation ( contains the following lines:

The following C types are pre-defined by the C parser (like a typedef, except re-declarations will be ignored):

Vararg handling: va_list, __builtin_va_list, __gnuc_va_list.
From <stddef.h>: ptrdiff_t, size_t, wchar_t.
From <stdint.h>: int8_t, int16_t, int32_t, int64_t, uint8_t, uint16_t, uint32_t, uint64_t, intptr_t, uintptr_t.

The problem is that hard erroring on these types means users of FFI who want to include an entire library's header files need to manually be careful to not include these definitions.

Additionally, the error message raised is incorrect, as it's not a syntax error but instead the redefinition of a known type.

Test script:

$cdef = '
typedef __builtin_va_list __gnuc_va_list;

$ffi = FFI::cdef($cdef, "/lib/x86_64-linux-gnu/");

Expected result:
valid FFI instance

Actual result:
Fatal error: Uncaught FFI\ParserException: unexpected '<ID>' at line 2 in test.php:7
Stack trace:
#0 test.php(7): FFI::cdef('\ntypedef __buil...', '/lib/x86_64-lin...')
#1 {main}
  thrown in test.php on line 7


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2019-03-19 14:30 UTC]
-Assigned To: +Assigned To: dmitry
 [2019-03-24 18:54 UTC]
-Summary: Builtin Types Should Not Raise Error On Redeclaration +Summary: FFI: Builtin Types Should Not Raise Error On Redeclaration
 [2019-03-28 21:03 UTC]
Automatic comment on behalf of
Log: Fixed bug #77768 (FFI: Builtin Types Should Not Raise Error On Redeclaration)
 [2019-03-28 21:03 UTC]
-Status: Assigned +Status: Closed
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Wed May 31 00:03:41 2023 UTC