-
Notifications
You must be signed in to change notification settings - Fork 605
Configure: Probe for size of intmax_t #24044
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: blead
Are you sure you want to change the base?
Conversation
2b49005 to
70bb6c6
Compare
|
Dies during |
d318d48 to
f4bb145
Compare
tonycoz
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks reasonable, but we do need to be careful when exposing intmax_t as part of the ABI.
Potentially compiler and/or libc updates, and compiler flags can change the size of intmax_t
Now that we require C99, we should be able to probe for this Some internal operations can benefit from using the widest type possible on the system, even if IVs and UVs don't use the full width. This data is kept in <stdint.h>, which should always be available in C99-compliant build systems. Configure has a 'i_stdint', but it comes much later in Configure than this does. I tried moving it to earlier, but then it relies on stuff that would have to get moved too, and I think that stuff has to be later. It gets complicated trying to deal with this value not existing, as there is a separate unit for 'long long', which would have to be considered. Until and unless some platform comes along that this doesn't work for, I just assume that this C99 construct will work as expected.
f4bb145 to
ace5874
Compare
|
@tonycoz This commit effectively only adds the ability to use the size of this in cpp #if statements. We already can use this typedef in ways that you caution about, so this commit adds no new bad outcomes that didn't already exist. And, FWIW, we already have public functions that work fine, and take parameters like this. |
The problem isn't whether it works now, the problem is whether a compiler or libc upgrade or compiler option will change the size of variant_byte_number() should be fairly safe, since it's static inline (it has no ABI), but for a function or type that's part of the ABI (parameter or return type of a function, member of a public struct) it's risky. Annoying as it is it might be better to probe for a large integer type to use for such cases to ensure we have a stable ABI. But I'm just saying be careful.
No, there's no reason for the compiler (or libc) to change the size of such types. Though I don't see much reason to use them for simple local variables or parameters, they save a tiny amount of stack space or none at all if the variable is allocated to a register. They can be useful in structs or arrays, the uses in next_matchable_info are good. Also, we can't be sure how the balance between speed and size were resolved, per the footnote in C23:
|
There are internal operations that use the widest integer type already. So fa,r not knowing its actual width at compile time has been worked around, but I'm planning enhancements that do need that value
And now that we require C99, the
intmax_ttype should always be available.