llvm-project
llvm-project copied to clipboard
[Clang] Rejects valid `void_t<>{}`
template <class...>
using void_t = void;
template <class T>
void f(T) {
::void_t<>{};
}
void g() {
f(0);
}
See https://compiler-explorer.com/z/E7aGq4dqY.
Output:
<source>:6:5: error: cannot initialize non-class type '::void_t<>' (aka 'void') with a parenthesized initializer list
6 | ::void_t<>{};
| ^ ~~
<source>:10:5: note: in instantiation of function template specialization 'f<int>' requested here
10 | f(0);
| ^
1 error generated.
@llvm/issue-subscribers-clang-frontend
Author: MagentaTreehouse
```c++
template <class...>
using void_t = void;
template <class T> void f(T) { ::void_t<>{}; }
void g() { f(0); }
See https://compiler-explorer.com/z/E7aGq4dqY.
Output:
```console
<source>:6:5: error: cannot initialize non-class type '::void_t<>' (aka 'void') with a parenthesized initializer list
6 | ::void_t<>{};
| ^ ~~
<source>:10:5: note: in instantiation of function template specialization 'f<int>' requested here
10 | f(0);
| ^
1 error generated.
The alias isn't needed, also happens with
template <class T>
void f(T) {
void{};
}
seems to be a missed case from https://github.com/llvm/llvm-project/pull/78060 when the expression is non-dependent in an instantiation.
Thanks for the report! I opened #228340 to fix the issue.