[clang] [Clang] Implement P2280R4 Using unknown pointers and references in constant expressions (PR #95474)

A. Jiang via cfe-commits cfe-commits at lists.llvm.org
Thu Jun 13 22:55:28 PDT 2024


================
@@ -1961,7 +1961,8 @@ namespace ConstexprConstructorRecovery {
 
 namespace Lifetime {
   void f() {
-    constexpr int &n = n; // expected-error {{constant expression}} expected-note {{use of reference outside its lifetime}} expected-warning {{not yet bound to a value}}
+    constexpr int &n = n; // expected-error {{constant expression}} cxx23-note {{reference to 'n' is not a constant expression}} cxx23-note {{address of non-static constexpr variable 'n' may differ}} expected-warning {{not yet bound to a value}}
+                          // cxx11_20-note at -1 {{use of reference outside its lifetime is not allowed in a constant expression}}
----------------
frederick-vs-ja wrote:

This looks strange. The old message looks better (see also [CWG453](https://cplusplus.github.io/CWG/issues/453.html)) and the new one is possibly misleading as we perhaps shoudn't say the address of a reference variable.

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


More information about the cfe-commits mailing list