[libcxx-commits] [clang] [libcxx] [Clang] Diagnose forming references to nullptr (PR #143667)

Timm Baeder via libcxx-commits libcxx-commits at lists.llvm.org
Wed Jul 2 07:06:02 PDT 2025


================
@@ -1662,9 +1662,11 @@ namespace NullptrCast {
   constexpr A *na = nullptr;
   constexpr B *nb = nullptr;
   constexpr A &ra = *nb; // both-error {{constant expression}} \
-                         // both-note {{cannot access base class of null pointer}}
+                         // ref-note {{read of dereferenced null pointer}} \
+                         // expected-note {{cannot access base class of null pointer}}
   constexpr B &rb = (B&)*na; // both-error {{constant expression}} \
-                             // both-note {{cannot access derived class of null pointer}}
+                             // ref-note {{read of dereferenced null pointer}} \
+                             // expected-note {{cannot access derived class of null pointer}}
----------------
tbaederr wrote:

Some of the new diagnostics seem like regressions.

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


More information about the libcxx-commits mailing list