clang rejects valid (T())(args...) function call with pack expansion #64926
Open
Description
Code to Reproduce
https://godbolt.org/z/Ef9P8fhP6
template<typename T, typename... Args>
void f(Args... args) {
(T())(args...);
}Output
<source>: In function 'void f(Args ...)':
<source>:3:19: error: expected ')' before '...' token
3 | (T())(args...);
| ~ ^~~
| )Explanation
(T())(args...) should be parsed as a:
- value-initialization of
T() - unnecessary parentheses
- pack expansion of the pack
args...into the function call operator ofT
This is how (T())() is interpreted (minus the pack expansion of course), and the same interpretation should apply to (T())(args...).
Activity