Skip to content

Fix alternate form flag for %x testing stale signed value - #248

Closed
iliaal wants to merge 1 commit into
PHP-8.4from
fix/snprintf-alternate-form-x
Closed

Fix alternate form flag for %x testing stale signed value#248
iliaal wants to merge 1 commit into
PHP-8.4from
fix/snprintf-alternate-form-x

Conversation

@iliaal

@iliaal iliaal commented Aug 21, 2026

Copy link
Copy Markdown
Owner

Fix the alternate-form flag for %x/%X gating the 0x prefix on i_num, which is only ever assigned by the decimal conversions; a standalone %#x printed no prefix and %d %#x consumed the earlier conversion's value.

The alternate-form branch for %x/%X gated the "0x" prefix on i_num,
which is only ever assigned by the signed/unsigned decimal
conversions. A standalone "%#x" with a nonzero value therefore
printed no prefix (i_num still held its zero initializer), while "%d
%#x" consumed the earlier conversion's value and could print a prefix
for zero.

Test the unsigned conversion result ui_num instead, matching the "0"
check the octal case already performs on the converted digits.
@iliaal

iliaal commented Aug 22, 2026

Copy link
Copy Markdown
Owner Author

Upstream: php#23410

@iliaal iliaal closed this Aug 22, 2026
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.

1 participant