Bug #77768 [Asn->Csd]: FFI: Builtin Types Should Not Raise Error On Redeclaration

From: Date: Thu, 28 Mar 2019 21:03:33 +0000
Subject: Bug #77768 [Asn->Csd]: FFI: Builtin Types Should Not Raise Error On Redeclaration
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-220243@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=77768&edit=1 ID: 77768 Updated by: dmitry@php.net Reported by: ircmaxell@php.net Summary: FFI: Builtin Types Should Not Raise Error On Redeclaration -Status: Assigned +Status: Closed Type: Bug Package: Unknown/Other Function PHP Version: Next Minor Version Assigned To: dmitry Block user comment: N Private report: N New Comment: Automatic comment on behalf of dmitry@zend.com Revision: http://git.php.net/?p=php-src.git;a=commit;h=a3e52afebe77517ca10d98ba57fefe3f178d56b6 Log: Fixed bug #77768 (FFI: Builtin Types Should Not Raise Error On Redeclaration) Previous Comments: ------------------------------------------------------------------------ [2019-03-19 14:30:15] ircmaxell@php.net Description: ------------ 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 (https://luajit.org/ext_ffi_semantics.html) 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: --------------- <?php $cdef = ' typedef __builtin_va_list __gnuc_va_list; '; $ffi = FFI::cdef($cdef, "/lib/x86_64-linux-gnu/libc.so.6"); 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 ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=77768&edit=1

« previous php.bugs (#220243) next »