Skip to content

Conversation

@jtracey
Copy link
Contributor

@jtracey jtracey commented Apr 28, 2025

#7837 added support for indexing in format strings, but allowed for an index of 0, treating it as equivalent to an index of 1. GNU rejects 0 indexes, which makes sense, as all the other indexes are 1-indexed, which means a user could encounter difficult to debug off-by-one errors if printf didn't return an error (e.g., if looping indexes from 0..$n).

This commit forbids 0 indexes, expressed at the type level with std::num::NonZero. Doing so also cuts the aligned size of ArgumentLocation in half, from two pointer widths to one, which is the sort of thing that could help some optimizations (I didn't run any benchmarks, the benefit is likely pretty tiny).

@github-actions
Copy link

GNU testsuite comparison:

Skip an intermittent issue tests/timeout/timeout (fails in this run but passes in the 'main' branch)
Skipping an intermittent issue tests/misc/stdbuf (passes in this run but fails in the 'main' branch)
Skipping an intermittent issue tests/tail/inotify-dir-recreate (passes in this run but fails in the 'main' branch)

@RenjiSann
Copy link
Collaborator

Great, Thanks !

@RenjiSann RenjiSann merged commit 279629f into uutils:main Apr 30, 2025
107 of 109 checks passed
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