[clang] [clang] Fix crashes when initializing constexpr int* with floating-point (PR #180376)

Samrudh Nelli via cfe-commits cfe-commits at lists.llvm.org
Mon Feb 9 06:13:49 PST 2026


================
@@ -8503,8 +8503,12 @@ ExprResult InitializationSequence::Perform(Sema &S,
         Expr::EvalResult ER;
         if (Entity.getType()->getAs<PointerType>() &&
             CurInit.get()->EvaluateAsRValue(ER, S.Context) &&
-            !ER.Val.isNullPointer()) {
+            // We continue and let it error later if Rvalue is not a pointer
+            ER.Val.isLValue() && 
+            !ER.Val.isNullPointer() &&
+            !ER.Val.getLValueBase().isNull()) {
----------------
SamrudhNelli wrote:

I originally added !getLValueBase().isNull() to preserve the existing error message for int values rather than returning the new error message (intended for floats). This was due to the reason that int values return true for Lvalue() and getValueBase().isNull().

https://github.com/llvm/llvm-project/pull/180376


More information about the cfe-commits mailing list