From b000459901bc1c5a55246da83550ad427ad4c4ff Mon Sep 17 00:00:00 2001 From: Eli Friedman Date: Mon, 24 Oct 2011 22:25:55 +0000 Subject: [PATCH] Don't try to emit CK_LValueBitCast casts as constants. PR9558. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@142863 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/CGExprConstant.cpp | 2 +- test/CodeGenCXX/const-init.cpp | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/CodeGen/CGExprConstant.cpp b/lib/CodeGen/CGExprConstant.cpp index 3997866ea6..31e0f2c3b0 100644 --- a/lib/CodeGen/CGExprConstant.cpp +++ b/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/test/CodeGenCXX/const-init.cpp b/test/CodeGenCXX/const-init.cpp index 797d1377f6..f06e546ec9 100644 --- a/test/CodeGenCXX/const-init.cpp +++ b/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("asd"); -- 2.40.0