-
Notifications
You must be signed in to change notification settings - Fork 13.4k
rejects valid (trunk) or compiler crash (18.x) when trying to deduce parameter type of template class inside template class #94614
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
@llvm/issue-subscribers-clang-frontend Author: Bruno Pitrus (brjsp)
```c++
namespace{ template<class, class>struct DoubleTrouble{};
private: } void boom(){
<source>:18:10: error: no viable constructor or deduction guide for deduction of template arguments of 'Inner'
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.
#0 0x00007ff06d5d9a09 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /home/abuild/rpmbuild/BUILD/llvm-18.1.6.src/lib/Support/Unix/Signals.inc:723:13
|
Note that with trunk, if we turn |
Reduced to a case that crashes on trunk: template <class, class>
struct S {};
template <class T, class U>
struct Outer {
using Trouble = S<U, T>;
template <class V>
struct Inner {
Inner(const V& v, Trouble* trouble) {}
};
};
void boom() {
S<int, char> s;
Outer<char, int>::Inner inner(42, &s);
} |
…lvm#94740) Similar to the approach of handling nested class templates when building a CTAD guide, we substitute the template parameters of a type alias declaration with the instantiating template arguments in order to ensure the guide eventually doesn't reference any outer template parameters. For example, ```cpp template <class T> struct Outer { using Alias = S<T>; template <class U> struct Inner { Inner(Alias); }; }; ``` we used to retain the reference to T accidentally because the TreeTransform does nothing on type alias Decls by default. Fixes llvm#94614
Clang trunk gives a bogus error message. There is no way
char
can get matched as the type ofV
:Clang 18 outright crashes, which alerted us to this error:
A workaround is to pass the parameter directly in constructor like
Inner<V>(v, &trouble_)
.See it on godbolt.
The text was updated successfully, but these errors were encountered: