diff --git a/flang/lib/Evaluate/real.cpp b/flang/lib/Evaluate/real.cpp --- a/flang/lib/Evaluate/real.cpp +++ b/flang/lib/Evaluate/real.cpp @@ -496,14 +496,17 @@ } } else { using B = decimal::BinaryFloatingPointNumber

; - const auto *value{reinterpret_cast(this)}; + typename B::RawType b{0}; + assert(sizeof b >= sizeof word_); + memcpy(&b, &word_, sizeof word_); + B value{b}; char buffer[24000]; // accommodate real*16 decimal::DecimalConversionFlags flags{}; // default: exact representation if (minimal) { flags = decimal::Minimize; } auto result{decimal::ConvertToDecimal

(buffer, sizeof buffer, flags, - static_cast(sizeof buffer), decimal::RoundNearest, *value)}; + static_cast(sizeof buffer), decimal::RoundNearest, value)}; const char *p{result.str}; if (DEREF(p) == '-' || *p == '+') { o << *p++;