[clang] Add tests for CWG issues 6, 212, 232, 2823. (PR #165633)

Vlad Serebrennikov via cfe-commits cfe-commits at lists.llvm.org
Thu Oct 30 02:34:05 PDT 2025


================
@@ -61,6 +61,22 @@ namespace cwg2819 { // cwg2819: 19 c++26
 #endif
 } // namespace cwg2819
 
+namespace cwg2823 { // cwg2823: no
+#if __cplusplus >= 201103L
+  constexpr int *p = 0;
+  constexpr int *q1 = &*p; // expected-error {{constant expression}} expected-note {{dereferencing a null pointer}}
----------------
Endilll wrote:

```suggestion
  constexpr int *q1 = &*p;
  // expected-error at -1 {{constexpr variable 'q1' must be initialized by a constant expression}}
  //   expected-note at -2 {{dereferencing a null pointer is not allowed in a constant expression}}
```

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


More information about the cfe-commits mailing list