c - 为什么 `__builtin_{{s,u}{add,sub,mul}ll_overflow` 给出 `long int` 结果而不是 `long long int` 结果?

标签 c gcc clang

GCC 中的溢出检查加法/减法/乘法内置函数的 int 版本返回一个 int 结果(良好),而 long int 版本返回一个 long int 结果(也不错),但是 long long int 版本返回一个 long int 结果(不好)。为什么是这样?我觉得这很疯狂。

例子:

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)

这太坏了,我什至不敢相信。这意味着在 longlong long 大小不同的目标上(例如,32 位 ARM iOS 目标),ll 版本的功能是完全无用的。

最佳答案

这是 GCC 中的一个错误,尚未修复。

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65007

关于c - 为什么 `__builtin_{{s,u}{add,sub,mul}ll_overflow` 给出 `long int` 结果而不是 `long long int` 结果?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30580978/

相关文章:

c - 用于将 rtspsrc 的名称元素与音频和视频队列链接的 Gstreamer 应用程序

将 Bash 脚本转换为 C。这可能吗?

c - FLAG=-DNDEBUG 没有在 C 中禁用 assert()

c - C 标准库结构在 macOS 或 Linux 上的编译器和库版本之间是否兼容?

c - 与 C scanf() 函数等效的 cmd 脚本是什么?

c - 扩展 ASCII 字符在 int 10h 中不起作用

c - 我在 SPOJ、语言 C、编译器 gcc 4.3.2 中收到以下代码的运行时错误:代码为 :

c++ - 尝试构建 muParser:错误:'std::basic_ostream 的显式实例化但没有可用的定义

c - 如何使用 Clang 从源代码中提取控制流图?

c - Xcode 4.6 (4H127),clang 警告 'illegal character encoding in string literal' ISO-8859-1 编码的 o-umlaut (0xF6)