[clang] [Clang] Fix the access checking for non-aggregates in default arguments (PR #141207)

via cfe-commits cfe-commits at lists.llvm.org
Fri May 23 01:43:19 PDT 2025


================
@@ -282,4 +283,25 @@ static_assert(S<short *>().SizeOfT<char>() == sizeof(short *), "");
 
 } // namespace GH68490
 
+namespace GH83608 {
+
+class single;
+
+class check_constructible {
+  // This makes it a non-aggregate in C++20+.
+  check_constructible() = default;
+
+  friend class single;
+};
+
+struct single {
+  template <class T> single(T u, check_constructible = {}) {}
+};
+
+// We perform access checking when substituting into the default argument.
+// Make sure it runs within class single.
----------------
cor3ntin wrote:

```suggestion
// Make sure it runs within the context of 'single'.
```

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


More information about the cfe-commits mailing list