Skip to content

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

Open
Marti2203 wants to merge 1 commit into
php:masterfrom
Marti2203:ffi-constexpr-values
Open

Marti2203 wants to merge 1 commit into
php:masterfrom
Marti2203:ffi-constexpr-values

Conversation

@Marti2203

Copy link
Copy Markdown
Contributor

Follow-up to #25575, which on PHP-8.4 now only fixes the SIGFPE crashes. This PR fixes the constant values from #25573 on master, since they change results:

  • '\a' evaluated to 0, and hex escapes with digits A-F were off by 10 ('\xA' was 0)
  • sizeof and __alignof__ of a character constant gave 1; a character constant has type int, so both are now 4 (as gcc gives)
  • _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
  • comparing an unsigned value with a character constant read the double member instead of the character
  • the operands of % must have integer type; a floating operand is now a parser error

Test: ext/ffi/tests/gh25573_values.phpt (fails before, passes after); ext/ffi tests 95/95.

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

- '\a' evaluated to 0, and hex escapes with digits A-F were off by 10
- sizeof and __alignof__ of a character constant gave 1 instead of the
  size and alignment of int
- _Alignas(N) used the alignment of N's type instead of N; _Alignas(0)
  now has no effect and a non-power-of-two alignment is an error
- comparing an unsigned value with a character constant read the
  double member instead of the character
- the operands of % must have integer type
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