Skip to content

fix(gen_stub): spell PHP_INT_MIN constants with ZEND_LONG_MIN - #48

Merged
matyhtf merged 1 commit into
swoole:masterfrom
AlessioGiacobbe:split/genstub-int-min
Sep 1, 2026
Merged

fix(gen_stub): spell PHP_INT_MIN constants with ZEND_LONG_MIN#48
matyhtf merged 1 commit into
swoole:masterfrom
AlessioGiacobbe:split/genstub-int-min

Conversation

@AlessioGiacobbe

Copy link
Copy Markdown
Contributor

const M = PHP_INT_MIN; (and property/parameter defaults with that value) made gen_stub emit ZVAL_LONG(&v, -9223372036854775808) — an ill-formed C literal (9223372036854775808 overflows long long before negation; clang warns, breaks under -Werror). The compiler's own genIntegerLiteral already spells this ZEND_LONG_MIN; getCExpr() now does the same.

Test pins the exact emitted literals.

Part of the split of #39.

getCExpr() emitted int class constants, property defaults and parameter
defaults with strval(), so `const M = PHP_INT_MIN;` produced
`ZVAL_LONG(&const_M_value, -9223372036854775808)`. C parses that as
unary minus applied to the literal 9223372036854775808, which exceeds
long long and is ill-formed, so the generated extension source does not
compile. The expression path already handles this via genIntegerLiteral
(ZEND_LONG_MIN); give the stub metadata path the same spelling.

The float paths (17-digit round-trip, -0.0 sign, INF/NAN) were already
fixed upstream in 2d81626; the new test pins those literals down
together with the int boundary values.
@matyhtf
matyhtf merged commit 284abdd into swoole:master Sep 1, 2026
14 checks passed
@AlessioGiacobbe
AlessioGiacobbe deleted the split/genstub-int-min branch September 1, 2026 11:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants