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

            Bug ID: 114753
           Summary: from_chars aborts with -m32 -ftrapv when passed
                    -9223372036854775808
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: gnu.ojxq8 at dralias dot com
  Target Milestone: ---

std::from_chars may abort when used with -m32 -ftrapv on some values.

Without -m32, or without -ftrapv, or using clang, the code works correctly.

To reproduce:

$ cat a.cpp 
#include <charconv>
#include <cstdint>
#include <string_view>
int main() {
  int64_t result{};
  std::string_view str{"-9223372036854775808"};
  (void)std::from_chars(str.begin(), str.end(), result);
  return result != -9223372036854775807 - 1;
}


$  g++ -m32 -ftrapv -std=c++17 ./a.cpp && ./a.out 
Aborted (core dumped)

Reply via email to