[all-commits] [llvm/llvm-project] bfcfc2: [libc] Fix typo in long double negative block (#68...

michaelrj-google via All-commits all-commits at lists.llvm.org
Wed Oct 4 13:01:01 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: bfcfc2a6d43f9cd86d66e7e68c03f3200bb1e366
      https://github.com/llvm/llvm-project/commit/bfcfc2a6d43f9cd86d66e7e68c03f3200bb1e366
  Author: michaelrj-google <71531609+michaelrj-google at users.noreply.github.com>
  Date:   2023-10-04 (Wed, 04 Oct 2023)

  Changed paths:
    M libc/src/__support/float_to_string.h
    M libc/test/src/stdio/sprintf_test.cpp

  Log Message:
  -----------
  [libc] Fix typo in long double negative block (#68243)

The long double version of float to string's get_negative_block had a
bug in table mode. In table mode, one of the tables is named
"MIN_BLOCK_2" and it stores the number of blocks that are all zeroes
before the digits start for a given index. The check for long doubles
was incorrectly "block_index <= MIN_BLOCK_2[idx]" when it should be
"block_index < MIN_BLOCK_2[idx]" (without the equal sign). This bug
caused an off-by-one error for some long double values. This patch fixes
the bug and adds tests to ensure it doesn't regress.




More information about the All-commits mailing list