Skip to content

Commit aaf83b5

Browse files
committed
Remove blank from NaN string representation
Flang front end function DumpHexadecimal generates a string representation of a REAL value. When the value is a NaN, the string contains a blank, as in "NaN 0x7fc00000". This function is used by lowering to generate a string that is then passed to llvm Support function convertFromStringSpecials, which does not expect a blank in the string. Remove the blank to allow correct recognition of a NaN by this llvm function. Note that function DumpHexadecimal is not exercised by the front end itself. This functionality is only exercised by code that is not yet present in llvm.
1 parent e8c242a commit aaf83b5

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

flang/lib/Evaluate/real.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,7 @@ ValueWithRealFlags<Real<W, P>> Real<W, P>::Read(
439439

440440
template <typename W, int P> std::string Real<W, P>::DumpHexadecimal() const {
441441
if (IsNotANumber()) {
442-
return "NaN 0x"s + word_.Hexadecimal();
442+
return "NaN0x"s + word_.Hexadecimal();
443443
} else if (IsNegative()) {
444444
return "-"s + Negate().DumpHexadecimal();
445445
} else if (IsInfinite()) {

flang/unittests/Evaluate/real.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ void dumpTest() {
2424
std::uint64_t raw;
2525
const char *expected;
2626
} table[] = {
27-
{0x7f876543, "NaN 0x7f876543"},
27+
{0x7f876543, "NaN0x7f876543"},
2828
{0x7f800000, "Inf"},
2929
{0xff800000, "-Inf"},
3030
{0x00000000, "0.0"},

0 commit comments

Comments
 (0)