-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Use uint32_t instead of size_t to store data in basic_specs? #4298
Comments
You are right that this doesn't need to be 64-bit but |
Why is The reason for this suggestion is because, when data_ being 64bit, the whole struct get 8B alignment and there will be 4B padding after the fill data. So it actually wastes 8B... https://en.cppreference.com/w/cpp/language/types#Properties Actually, I think #4200 is taking about Lines 747 to 749 in 093b39c
But size should be less than fill_size_mask(and set_fill guaruantees that), don't really see a reason to enlarge data_ decause of it. For the concern of -Wuseless-cast , pragma ignored could help...
|
uint32_t was introduced in C++11 (resp. C99), support of theses fixed width types can be safely assumed |
It is not guaranteed to exist by the standard. I don't have specific examples at hand but know that {fmt} is compiled on all kinds of weird platforms, even without |
Vitaut, you are right, std::uint32_t exists only if the platform supports an unsigned integral type that is exactly 32 bits wide and has no padding. It is optional in the standard - I was not aware of this. |
|
In recent refactoring, I can see core format spec are now stored in single
data_
element, but the type issize_t
, which varies in 32bit/64bit mode.fmt/include/fmt/base.h
Line 742 in 093b39c
Since it's not storing pointer information and according to the masks, at most 32bit will be used, is it better to change the type to uint32_t?
fmt/include/fmt/base.h
Lines 705 to 740 in 093b39c
The text was updated successfully, but these errors were encountered: