https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106865
cqwrteur <unlvsur at live dot com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |unlvsur at live dot com --- Comment #1 from cqwrteur <unlvsur at live dot com> --- https://godbolt.org/z/rsETjYvh4 template<typename T> inline constexpr bool add_carry2(bool carryin,T a,T b,T& res) noexcept { res=carryin+a; T carry_temp{res<a}; res+=b; carry_temp+=res<b; if(carry_temp>1u) { __builtin_unreachable(); } return carry_temp; } Also pattern like this for msvc compatibility.