[clang] [Clang] Fix constexpr __builtin_(add|sub|mul)_overflow bugs (PR #192568)
Shafik Yaghmour via cfe-commits
cfe-commits at lists.llvm.org
Thu May 7 11:48:42 PDT 2026
================
@@ -1964,6 +1964,53 @@ namespace I128Mul {
}
#endif
+namespace OverflowOps {
+ constexpr bool add_bool() {
+ bool r = false;
+ return __builtin_add_overflow(1u, 1u, &r) && r == false;
----------------
shafik wrote:
I am curious what we expect for:
```cpp
constexpr bool add_bool() {
bool r = false;
return __builtin_add_overflow(true, true, &r) && r == false;
}
static_assert(add_bool());
```
I would also note gcc does not seem to like the third argument: https://gcc.godbolt.org/z/nT56hx935
https://github.com/llvm/llvm-project/pull/192568
More information about the cfe-commits
mailing list