Skip to content

clang rejects valid (T())(args...) function call with pack expansion #64926

Open
@Eisenwave

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 of T

This is how (T())() is interpreted (minus the pack expansion of course), and the same interpretation should apply to (T())(args...).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    clang:frontendLanguage frontend issues, e.g. anything involving "Sema"

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions