Skip to content
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

clang: pack expansion contains parameter pack 'Args' that has a different length (1 vs. 2) from outer parameter packs #64902

Closed
jcelerier opened this issue Aug 22, 2023 · 3 comments
Labels
clang:frontend Language frontend issues, e.g. anything involving "Sema" rejects-valid

Comments

@jcelerier
Copy link

jcelerier commented Aug 22, 2023

Hello,

repro:

#include <functional>

struct worker {
    std::function<void(int, int)> request;
    static void work(int, int);
} worker;

template <typename T = int>
void connect_worker() {
    worker.request = []<typename... Args>(Args&&... f) {
        [... ff = std::forward<Args>(f)]() mutable {
            worker::work(std::forward<Args>(ff)...);
        }();
    };
}

int main() { connect_worker(); }

causes:

<source>:14:48: error: pack expansion contains parameter pack 'Args' that has a different length (1 vs. 2) from outer parameter packs
            worker::work(std::forward<Args>(ff)...);
                                      ~~~~     ^

I'm confident this is a compiler bug as if one turns connect_worker into a non-template by removing template <typename T = int>, then the code builds and runs as expected:

https://gcc.godbolt.org/z/YM6ar7WG3

also,

static_assert(sizeof...(Args) == 2);

Just before the offending line passes too.

Not forwarding the arguments works too:

worker::work(ff...);
@shafik
Copy link
Collaborator

shafik commented Aug 22, 2023

Maybe duplicate of: #61415

CC @erichkeane

@EugeneZelenko EugeneZelenko added clang:frontend Language frontend issues, e.g. anything involving "Sema" and removed new issue labels Aug 22, 2023
@llvmbot
Copy link
Member

llvmbot commented Aug 22, 2023

@llvm/issue-subscribers-clang-frontend

@zyn0217
Copy link
Contributor

zyn0217 commented Dec 19, 2024

Should have been fixed by #101385

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:frontend Language frontend issues, e.g. anything involving "Sema" rejects-valid
Projects
None yet
Development

No branches or pull requests

5 participants