[all-commits] [llvm/llvm-project] ce4d67: [libc][NFC] make atoi undefined cases match std

michaelrj-google via All-commits all-commits at lists.llvm.org
Tue Dec 20 10:21:38 PST 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: ce4d6717f85eeddd0b374d2829f46548972c5d4e
      https://github.com/llvm/llvm-project/commit/ce4d6717f85eeddd0b374d2829f46548972c5d4e
  Author: Michael Jones <michaelrj at google.com>
  Date:   2022-12-20 (Tue, 20 Dec 2022)

  Changed paths:
    M libc/src/stdlib/atoi.cpp
    M libc/test/src/stdlib/AtoiTest.h

  Log Message:
  -----------
  [libc][NFC] make atoi undefined cases match std

The standard describes atoi as:

"equivalent to atoi: (int)strtol(nptr, (char **)NULL, 10)"

Previously, our behavior was slightly different on numbers larger than
INT_MAX, but this patch changes it to just do the cast instead. Both of
these are valid since the standard says

"If the value of the result cannot be represented, the
behavior is undefined."

But matching existing behavior makes differential fuzzing easier.

Reviewed By: sivachandra

Differential Revision: https://reviews.llvm.org/D140350




More information about the All-commits mailing list