[clang] [Clang] Fix crash when ill-formed code is treated as a deduction guide (PR #67373)

Richard Smith via cfe-commits cfe-commits at lists.llvm.org
Mon Sep 25 16:07:40 PDT 2023


================
@@ -171,3 +171,12 @@ namespace CtorTemplateBeatsNonTemplateConversionFn {
   Foo f(Derived d) { return d; } // expected-error {{invokes a deleted function}}
   Foo g(Derived d) { return Foo(d); } // ok, calls constructor
 }
+
+namespace GH65522 {
+template<typename A3>
+class B3 : A3 {
+  template<bool = C3<B3>()> // expected-warning 2{{use of function template name with no prior declaration in function call with explicit}}
+  B3();
+}; B3(); // expected-error {{deduction guide declaration without trailing return type}} \
+         // expected-note {{while building deduction guide here}}
----------------
zygoloid wrote:

Do we need an invalid deduction guide here to hit this problem? If I'm understanding correctly, what's happening here is:

- The explicit deduction guide (that's not actually a deduction guide at all) triggers generation of implicit deduction guides.
- Generating an implicit deduction guide produces a warning.
- The warning has the implicit deduction guide on the stack, hitting the `unreachable`

If so, I think it would be clearer to write the test in a way that doesn't produce an error:
```suggestion
};

constexpr bool C3(...) { return true; }
B3 b3; // expected-note {{while building deduction guide here}}
```

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


More information about the cfe-commits mailing list