[Bug c++/70507] integer overflow builtins not constant expressions

msebor at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Mon Apr 4 15:08:00 GMT 2016


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

--- Comment #2 from Martin Sebor <msebor at gcc dot gnu.org> ---
Thank you for the suggestion.

Storing values via pointers is not C++ 14 specific so the answer to your
question is that having the builtins be treated as constexpr would be useful in
both C++ 11 and C++ 14 modes.  The modified example below should help explain
it:

constexpr int mul (int x, int y, int z = 0)
{
  return __builtin_mul_overflow *(x, y, &z) ? 0 : z;
}

constexpr int z = mul (1234, 5678);


More information about the Gcc-bugs mailing list