Bug #77768 [NEW]: Builtin Types Should Not Raise Error On Redeclaration
| From: | ircmaxell@php.net | Date: | Tue, 19 Mar 2019 14:30:15 +0000 |
| Subject: | Bug #77768 [NEW]: Builtin Types Should Not Raise Error On Redeclaration | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-220076@lists.php.net to get a copy of this message | ||
From: ircmaxell
Operating system:
PHP version: Next Minor Version
Package: Unknown/Other Function
Bug Type: Bug
Bug description:Builtin Types Should Not Raise Error On Redeclaration
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 bug report at https://bugs.php.net/bug.php?id=77768&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=77768&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=77768&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=77768&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=77768&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=77768&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=77768&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=77768&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=77768&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=77768&r=support
Expected behavior: https://bugs.php.net/fix.php?id=77768&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=77768&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=77768&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=77768&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=77768&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=77768&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=77768&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=77768&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=77768&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=77768&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=77768&r=mysqlcfg