_REALLY_ fix the float constant problem
authorChris Lattner <sabre@nondot.org>
Thu, 7 Nov 2002 22:12:53 +0000 (22:12 +0000)
committerChris Lattner <sabre@nondot.org>
Thu, 7 Nov 2002 22:12:53 +0000 (22:12 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@4609 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/CBackend/CBackend.cpp
lib/Target/CBackend/Writer.cpp

index 3a0fbe99b9b32b204f82f14747ce762dad2cdc11..f318764b026919529e72a2087e5b23632a4d85ea 100644 (file)
@@ -778,11 +778,12 @@ void CWriter::printFunction(Function *F) {
           Out << "  const ConstantDoubleTy FloatConstant" << FPCounter++
               << " = 0x" << std::hex << *(unsigned long long*)&Val << std::dec
               << ";    /* " << Val << " */\n";
-        else if (FPC->getType() == Type::FloatTy)
+        else if (FPC->getType() == Type::FloatTy) {
+          float fVal = Val;
           Out << "  const ConstantFloatTy FloatConstant" << FPCounter++
-              << " = 0x" << std::hex << *(unsigned*)&Val << std::dec
+              << " = 0x" << std::hex << *(unsigned*)&fVal << std::dec
               << ";    /* " << Val << " */\n";
-        else
+        else
           assert(0 && "Unknown float type!");
       }
 
index 3a0fbe99b9b32b204f82f14747ce762dad2cdc11..f318764b026919529e72a2087e5b23632a4d85ea 100644 (file)
@@ -778,11 +778,12 @@ void CWriter::printFunction(Function *F) {
           Out << "  const ConstantDoubleTy FloatConstant" << FPCounter++
               << " = 0x" << std::hex << *(unsigned long long*)&Val << std::dec
               << ";    /* " << Val << " */\n";
-        else if (FPC->getType() == Type::FloatTy)
+        else if (FPC->getType() == Type::FloatTy) {
+          float fVal = Val;
           Out << "  const ConstantFloatTy FloatConstant" << FPCounter++
-              << " = 0x" << std::hex << *(unsigned*)&Val << std::dec
+              << " = 0x" << std::hex << *(unsigned*)&fVal << std::dec
               << ";    /* " << Val << " */\n";
-        else
+        else
           assert(0 && "Unknown float type!");
       }