]> granicus.if.org Git - llvm/commitdiff
[APFloat] APFloat::Storage::Storage - fix use after move
authorSimon Pilgrim <llvm-dev@redking.me.uk>
Tue, 14 May 2019 14:13:30 +0000 (14:13 +0000)
committerSimon Pilgrim <llvm-dev@redking.me.uk>
Tue, 14 May 2019 14:13:30 +0000 (14:13 +0000)
This was mentioned both in https://www.viva64.com/en/b/0629/ and by scan-build checks

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@360675 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Support/APFloat.cpp

index 208950d7ab714b3052b51161b6025de441217307..aea59301079e768eb8a666b1780b3508b0c27cec 100644 (file)
@@ -4418,9 +4418,9 @@ APFloat::Storage::Storage(IEEEFloat F, const fltSemantics &Semantics) {
     return;
   }
   if (usesLayout<DoubleAPFloat>(Semantics)) {
-    new (&Double)
-        DoubleAPFloat(Semantics, APFloat(std::move(F), F.getSemantics()),
-                      APFloat(semIEEEdouble));
+    const fltSemantics IEEESemantics = F.getSemantics();
+    new (&Double) DoubleAPFloat(Semantics, APFloat(std::move(F), IEEESemantics),
+                                APFloat(semIEEEdouble));
     return;
   }
   llvm_unreachable("Unexpected semantics");