[Bug c++/114753] from_chars aborts with -m32 -ftrapv when passed -9223372036854775808

2024-04-17 Thread redi at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114753

--- Comment #2 from Jonathan Wakely  ---
(In reply to Jonathan Wakely from comment #1)
> With __val = 9223372036854775808LL __sign = -1LL

Oops, that should be __val = 9223372036854775808ULL and __sign = -1

i.e.

int main()
{
  unsigned long long val = 9223372036854775808ULL;
  int sign = -1;
  long long res;
  return __builtin_mul_overflow(val, sign, );
}

This shouldn't trap.

[Bug c++/114753] from_chars aborts with -m32 -ftrapv when passed -9223372036854775808

2024-04-17 Thread redi at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114753

Jonathan Wakely  changed:

   What|Removed |Added

 Ever confirmed|0   |1
   Last reconfirmed||2024-04-17
 Status|UNCONFIRMED |NEW

--- Comment #1 from Jonathan Wakely  ---
The abort happens here:

  if (__builtin_mul_overflow(__val, __sign, &__tmp))

With __val = 9223372036854775808LL __sign = -1LL

The libgcc2.c:__mulvdi3 function reaches the abort() on line 375