diff options
author | Ehud Katz <ehudkatz@gmail.com> | 2020-01-07 11:24:11 +0200 |
---|---|---|
committer | Ehud Katz <ehudkatz@gmail.com> | 2020-01-07 11:24:18 +0200 |
commit | 63a222e504c2f6f1e4f60f8d2acfb5870cac9c66 (patch) | |
tree | 8cb1b8addf180350e691825451f3b404348569f3 /llvm/lib/Support/APFloat.cpp | |
parent | 5a9c24b5721b9becd642a6801eb46f1205e54ca0 (diff) | |
download | bcm5719-llvm-63a222e504c2f6f1e4f60f8d2acfb5870cac9c66.tar.gz bcm5719-llvm-63a222e504c2f6f1e4f60f8d2acfb5870cac9c66.zip |
[APFloat] Fix out of scope usage of a pointer to local variable
Diffstat (limited to 'llvm/lib/Support/APFloat.cpp')
-rw-r--r-- | llvm/lib/Support/APFloat.cpp | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/llvm/lib/Support/APFloat.cpp b/llvm/lib/Support/APFloat.cpp index 723bbbc176b..f8a217d3535 100644 --- a/llvm/lib/Support/APFloat.cpp +++ b/llvm/lib/Support/APFloat.cpp @@ -1065,18 +1065,22 @@ lostFraction IEEEFloat::multiplySignificand(const IEEEFloat &rhs, significand.parts = fullSignificand; semantics = &extendedSemantics; - status = addend.convert(extendedSemantics, rmTowardZero, &ignored); + // Make a copy so we can convert it to the extended semantics. + // Note that we cannot convert the addend directly, as the extendedSemantics + // is a local variable (which we take a reference to). + IEEEFloat extendedAddend(addend); + status = extendedAddend.convert(extendedSemantics, rmTowardZero, &ignored); assert(status == opOK); (void)status; // Shift the significand of the addend right by one bit. This guarantees // that the high bit of the significand is zero (same as fullSignificand), // so the addition will overflow (if it does overflow at all) into the top bit. - lost_fraction = addend.shiftSignificandRight(1); + lost_fraction = extendedAddend.shiftSignificandRight(1); assert(lost_fraction == lfExactlyZero && "Lost precision while shifting addend for fused-multiply-add."); - lost_fraction = addOrSubtractSignificand(addend, false); + lost_fraction = addOrSubtractSignificand(extendedAddend, false); /* Restore our state. */ if (newPartsCount == 1) |