Skip to content

Fix GH-25573: FFI constant expression values - #25724

Open
Marti2203 wants to merge 5 commits into
php:masterfrom
Marti2203:ffi-constexpr-values
Open

Marti2203 wants to merge 5 commits into
php:masterfrom
Marti2203:ffi-constexpr-values

Conversation

@Marti2203

@Marti2203 Marti2203 commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Follow-up to #25575, which on PHP-8.4 fixes the SIGFPE crashes and the hex escapes. This PR fixes the other constant values from #25573 on master, since they change results. One commit per fix, each with its own test (fails before, passes after):

  • '\a' evaluated to 0 (gh25573_bell.phpt)
  • sizeof and __alignof__ of a character constant gave 1; a character constant has type int, so both are now 4, as gcc gives (gh25573_char_sizeof.phpt)
  • _Alignas(N) used the alignment of N's type (4 or 8) instead of N; _Alignas(0) now has no effect and a non-power-of-two alignment is a parser error (gh25573_alignas.phpt)
  • comparing an unsigned value with a character constant read the double member instead of the character (gh25573_char_cmp.phpt)
  • the operands of % must have integer type; a floating operand is now a parser error (gh25573_mod_float.phpt)

ext/ffi tests 99/99.

This issue was found by an LLM-assisted tool and verified manually.

'\a' did not set the value, so it evaluated to 0.
In C a character constant has type int, but sizeof and __alignof__ of one
gave 1.
_Alignas(N) used the alignment of N's type instead of N. _Alignas(0) now
has no effect, and an alignment that is not a power of two is an error.
The comparison read the double member of the character constant
instead of the character.
The operands of % must have integer type.
@Marti2203
Marti2203 force-pushed the ffi-constexpr-values branch from dbd8364 to aa4a8db Compare November 26, 2026 00:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant