[clang] [clang] Fix C++20 list initialization of const references to arrays of unknown bound (PR #218225)

Younan Zhang via cfe-commits cfe-commits at lists.llvm.org
Wed Aug 26 04:14:34 PDT 2026


================
@@ -19,3 +19,23 @@ void foo(int a) {
 // CHECK-NEXT:            `-InitListExpr 0x{{[^ ]*}} <col:5, col:7> 'int[1]'
 // CHECK-NEXT:              `-ImplicitCastExpr 0x{{[^ ]*}} <col:6> 'int' <LValueToRValue>
 // CHECK-NEXT:                `-DeclRefExpr 0x{{[^ ]*}} <col:6> 'int' lvalue ParmVar 0x{{[^ ]*}} 'a' 'int'
+
+void bar(int a) {
+  auto g = [](const int(&)[]) {};
+  g({a});
+}
+
+// Same as above, but binding to a const lvalue reference: the cast to the
+// incomplete array type is an lvalue rather than an xvalue.
+
----------------
zyn0217 wrote:

I would preserve only 1 test. They are duplicate anyway

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


More information about the cfe-commits mailing list