[clang] [CodeGen] Fix handling of nullptr in initializers (PR #137364)

John McCall via cfe-commits cfe-commits at lists.llvm.org
Fri Apr 25 11:34:54 PDT 2025


================
@@ -121,6 +121,7 @@ CAST_OPERATION(FunctionToPointerDecay)
 /// CK_NullToPointer - Null pointer constant to pointer, ObjC
 /// pointer, or block pointer.
 ///   (void*) 0
+///   (void*) nullptr
----------------
rjmccall wrote:

I think Eli is asking for you to note in the text that the result of this conversion can still be a null pointer constant if it has type `std::nullptr_t`. While the conversion does always produce *null pointer values*, it does not otherwise produce *null pointer constants* as defined by the C++ standard. Only integer literal 0 and pr-values of type `std::nullptr_t` are null pointer constants.

I don't think we should have `(std::nullptr_t) x` in the list of examples because that is not generally a valid conversion.

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


More information about the cfe-commits mailing list