[clang] [clang] Fix a crash when default argument is passed to an explicit object parameter (PR #177534)

Shafik Yaghmour via cfe-commits cfe-commits at lists.llvm.org
Sat Jan 31 15:43:17 PST 2026


================
@@ -1431,6 +1431,30 @@ namespace ConstexprBacktrace {
                           // expected-note {{in call to}}
 }
 
+namespace GH176639 {
+
+struct S {
+  void operator()(this S =) // expected-error {{the explicit object parameter cannot have a default argument}}
+          // expected-error at -1 {{expected ';' at end of declaration list}}
+          // expected-error at -2 {{expected expression}}
+};
+
+void foo() {
+  S s{};
+  s(0); // expected-error {{no matching function for call to object of type 'S'}}
+}
+
+struct S2 {
+  void operator()(this S2 = S2 {}){} // expected-error {{the explicit object parameter cannot have a default argument}}
----------------
shafik wrote:

I think another useful test would have been `{}` alone as well.

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


More information about the cfe-commits mailing list