OSDN Git Service

APFloat/x87: Fix string conversion for "unnormal" values (pr35860)
authorPavel Labath <labath@google.com>
Wed, 9 May 2018 15:13:45 +0000 (15:13 +0000)
committerPavel Labath <labath@google.com>
Wed, 9 May 2018 15:13:45 +0000 (15:13 +0000)
commit277cedda80e89ae6d46a17709a62ab969a7df05b
treea0992b85337759333ff4136196ee1c59ef437bb5
parent4549ddbb6848a1921b21efcb164e02d051bc3c78
APFloat/x87: Fix string conversion for "unnormal" values (pr35860)

Summary:
Unnormal values are a feature of some very old x87 processors. We handle
them correctly for the most part -- the only exception was an unnormal
value whose significand happened to be zero. In this case the APFloat
was still initialized as normal number (category = fcNormal), but a
subsequent toString operation would assert because the math would
produce nonsensical values for the zero significand.

During review, it was decided that the correct way to fix this is to
treat all unnormal values as NaNs (as that is what any >=386 processor
will do).

The issue was discovered because LLDB would crash when trying to print
some "long double" values.

Reviewers: skatkov, scanon, gottesmm

Subscribers: llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@331884 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Support/APFloat.cpp
unittests/ADT/APFloatTest.cpp