-
Notifications
You must be signed in to change notification settings - Fork 14.9k
Description
The following code (minimal repro. example)
template <typename T>
struct X {};
template <typename>
using DistinctCollector = X<decltype([]{})>;
DistinctCollector<int*> getCellSpreadItems()
{
DistinctCollector<int*> set;
return set;
}
int main() { getCellSpreadItems(); }
https://godbolt.org/z/obMWeKjKr
fails with
error: no viable conversion from returned value of type 'DistinctCollector<...>' to function return type 'DistinctCollector<...>'
The same error is not observed on GCC or MSVC (in conformance mode, iow /permissive-
) compilers.
If you use
auto getCellSpreadItems()
{
DistinctCollector<int*> set;
return set;
}
https://godbolt.org/z/4fnocEr13
it works.
Per @Sirraide on Discord:
Looking at the AST, it seems like we’re instantiating that template twice; so it seems what it’s complaining about is that the two instances of
DistinctCollector<T>
are ... not the same type, which er, is not quite right
There are some things we try to diagnose even if the function is still dependent, but usually you need to instantiate it yes, and this also looks like a problem specifically w/ instantiation