[all-commits] [llvm/llvm-project] eab63b: [libc] Fix %m on CPUs with float128 but no int128 ...

Michael Jones via All-commits all-commits at lists.llvm.org
Wed Sep 25 15:31:10 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: eab63b5a8cf2214ddfee566a87deb3013ffcc362
      https://github.com/llvm/llvm-project/commit/eab63b5a8cf2214ddfee566a87deb3013ffcc362
  Author: Michael Jones <michaelrj at google.com>
  Date:   2024-09-25 (Wed, 25 Sep 2024)

  Changed paths:
    M libc/src/stdio/printf_core/parser.h

  Log Message:
  -----------
  [libc] Fix %m on CPUs with float128 but no int128 (#110053)

This bug is caused by the BigInt implementation failing to initialize
from errno. Explanation below, but the fix is a static cast to int.

The bug only shows up on risc-v 32 because of a chain of type-oddities:
1) Errno is provided by a struct with an implicit cast to int.
2) The printf parser uses an int128 to store the value of a conversion
   on systems with long double greater than double.
3) On systems without native int128 support we use our own BigInt
instead.

These combine such that if both long double and int128 exist (e.g. on
x86) there's no issue, errno is implicitly cast to int, which is
extended to int128. If long double is double (e.g. on arm32) then int64
is used in the printf parser, the implicit cast works, and there's no
issue. The only way this would come up is if the target has a proper
long double type, but not int128, which is the case for at least the
current risc-v 32 bot.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list