diff --git a/clang/lib/CodeGen/CGExprConstant.cpp b/clang/lib/CodeGen/CGExprConstant.cpp index 3997866ea68e..31e0f2c3b0e2 100644 --- a/clang/lib/CodeGen/CGExprConstant.cpp +++ b/clang/lib/CodeGen/CGExprConstant.cpp @@ -573,7 +573,6 @@ public: case CK_CPointerToObjCPointerCast: case CK_BlockPointerToObjCPointerCast: case CK_AnyPointerToBlockPointerCast: - case CK_LValueBitCast: case CK_BitCast: if (C->getType() == destType) return C; return llvm::ConstantExpr::getBitCast(C, destType); @@ -589,6 +588,7 @@ public: case CK_ARCConsumeObject: case CK_ARCReclaimReturnedObject: case CK_ARCExtendBlockObject: + case CK_LValueBitCast: return 0; // These might need to be supported for constexpr. diff --git a/clang/test/CodeGenCXX/const-init.cpp b/clang/test/CodeGenCXX/const-init.cpp index 797d1377f698..f06e546ec9a6 100644 --- a/clang/test/CodeGenCXX/const-init.cpp +++ b/clang/test/CodeGenCXX/const-init.cpp @@ -36,3 +36,7 @@ namespace test2 { double t0 = A::d; double t1[] = { A::d, A::f }; } + +// We don't expect to fold this in the frontend, but make sure it doesn't crash. +// CHECK: @PR9558 = global float 0.000000e+0 +float PR9558 = reinterpret_cast<const float&>("asd");