Skip to content

Reject overflowing printf argument indices - #5055

Open
yss25 wants to merge 1 commit into
fmtlib:mainfrom
yss25:codex/fix-printf-positional-index-overflow
Open

yss25 wants to merge 1 commit into
fmtlib:mainfrom
yss25:codex/fix-printf-positional-index-overflow

Conversation

@yss25

@yss25 yss25 commented Dec 2, 2026

Copy link
Copy Markdown

fmt::sprintf("%*2147483648$d", 5, 42) returns " 42" instead of rejecting the index. The overflow sentinel -1 gets treated as automatic indexing.

Keep overflowing width and precision indices on the out-of-range path. Add regressions for INT_MAX + 1 and longer indices.

Tested with MSVC on Windows x64: all 44 printf tests pass. The full suite passes 20/22; the same two locale tests fail on the unmodified base.

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