You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
FFI constant expressions: 1/0 crashes; '\a', hex escapes, sizeof('a'), _Alignas(N) and some comparisons are evaluated wrongly #25573
Several errors in the evaluation of C constant expressions in FFI::cdef() (array sizes, enum values, _Alignas). Each line below shows what FFI computes and what C gives (gcc).
Division by zero crashes the process.zend_ffi_expr_div() / zend_ffi_expr_mod() divide without
checking the divisor:
Result: Floating point exception (core dumped) (exit 136). The same for 1 % 0 and for (-9223372036854775807 - 1) / -1. Expected: an FFI\ParserException, as for other invalid declarations.
Result: int(4). Expected: int(16). (_Alignas(double), the type form, works.)
Unsigned vs character comparison reads the wrong union member. In zend_ffi_expr_cmp, the
unsigned-vs-CHAR case compares val->u64 OP op2->d, but only op2->ch is set, so the result depends
on stale memory:
Result: int(13) int(7) (the same expression gives two answers). Expected: int(7) int(7).
Mixed signed/unsigned comparisons do not follow C's conversions.(0xFFFFFFFFu == -1) is false
(C: true, both operands become unsigned int) and (-1 < 1u) is true (C: false). The comparison macro
compares i64 against u64 directly (/* signed/unsigned */). This one needs the usual arithmetic
conversions and is not changed by the patch below.
Activity
Keep the FFI instance alive in the phpGH-25573 test