Support for fixed-width integers#338
Open
stefano-zanotti-88 wants to merge 7 commits intocharlesnicholson:mainfrom
Open
Support for fixed-width integers#338stefano-zanotti-88 wants to merge 7 commits intocharlesnicholson:mainfrom
stefano-zanotti-88 wants to merge 7 commits intocharlesnicholson:mainfrom
Conversation
Sync with original repo
Open
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This adds support for the "wN" and "wfN" length modifiers.
The standard:
So:
[u]int<N>_ttypes. In NPF, I've assumed that they do exist.[unsigned] _BitInt(N)types, which would be impossible to do in a standard-conforming way, since there can be arbitrarily many such types (it seems that clang supports up to N = 2**24), and since they do not impose the same alignment restrictions as[u]int<N>_tdo, and there is no way to distinguish[u]int<N>_tfrom_BitInt(N), in a printf call.I'm mentioning this because
_BitInt(N)"should" be treated like any other integer:though the printf specs explicitly mentions only the traditional fixed-width integers.
Indeed, GCC seems to support printing only of
[u]int<N>_tand similar; it doesn't parse N as valid, for N values that are not in [8, 16, 32, 64]. It does not support 128 either, though there are extension types__[u]int128See also the C proposal N2858 (mentioned in #126) -- it seems to imply that, indeed,
_BitInt(N)is outside of the scope ofw<N>andwf<N>, since it would get its ownwb<N>.In summary, with this PR, NPF supports:
w8, w16, w32, w64
wf8, wf16, wf32, w6f4
Here are the test cases I checked it against. I haven't integrated them in the tests for now.
The require_conform function is the same used in conformance.cc.
To test the %n specifier, I've used a different one, which also tests against buffer overrun (ie the writeback uses a pointer of the wrong type), which would be useful also for the %n tests that already exist in conformance.cc.