-
Notifications
You must be signed in to change notification settings - Fork 570
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
FIX: store_be(size_t(42)) would not compile on Xcode #4126
Conversation
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.
Thanks! XCode hates this one weird trick.
The affected platform defines uint64_t as "unsigned long long" and size_t as "unsigned long int". Both are 64bit types, but the compiler failed to call reverse_bytes() for size_t regardless. It claimed the call is ambiguous.
I'm confused why you would ever want to do this. The number of bytes written will depend on the size of size_t, which means it's not really useful for serialization. What am I missing? |
This is not supposed to change any behavior. It's just working around Xcode's compiler not being able to dispatch the overload of See here for a build failure on macOS: https://github.com/randombit/botan/actions/runs/9515856655/job/26230969296?pr=4119 |
Sure but my point was that we had not hit this so far because saying I looked at the specific code in |
True! I didn't even think of that. But that answers: "How did that ever work?" 🤣 |
Xcode defines uint64_t as "unsigned long long" and size_t as "unsigned long int". Both are 64bit types, but the compiler failed to call reverse_bytes() for size_t regardless. It claimed the call is ambiguous. This was initially found by @FAlbertDev in #4119.
The workaround makes
reverse_bytes()
an (awful) template that just assumes to get astd::unsigned_integral T
and disambiguates onsizeof(T)
using if constexpr. I'm certainly open to better ideas. But then again: C++23 will obsolete this anyway.