The int
versions of the overflow-checking add/subtract/multiply builtins in GCC return an int
result (good), and the long int
versions return a long int
result (also good), but the long long int
versions return a long int
result (not good). Why is this? It seems insane to me.
Example:
bool __builtin_uadd_overflow (unsigned int a, unsigned int b, unsigned int *res)
bool __builtin_uaddl_overflow (unsigned long int a, unsigned long int b, unsigned long int *res)
bool __builtin_uaddll_overflow (unsigned long long int a, unsigned long long int b, unsigned long int *res)
This is so broken, I can't even believe it. It means that on a target where long
and long long
are different sizes (for example, 32-bit ARM iOS targets), the ll
versions of the functions are completely useless.
This is a bug in GCC that hasn't been fixed yet.
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65007
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With