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-tidy][C++20] False negative modernize-use-emplace when passing init list #104434

Open
chrchr-github opened this issue Aug 15, 2024 · 1 comment

Comments

@chrchr-github
Copy link

#include <string>
#include <vector>

struct S {
    std::string s;
};

void f(std::string a) {
    std::vector<S> v;
    v.push_back({std::move(a)}); // no warning
}

https://godbolt.org/z/4jrj1M6hY
With C++20, v.emplace_back(std::move(a)); should be used.

@llvmbot
Copy link
Collaborator

llvmbot commented Aug 15, 2024

@llvm/issue-subscribers-c-20

Author: None (chrchr-github)

~~~c++ #include <string> #include <vector>

struct S {
std::string s;
};

void f(std::string a) {
std::vector<S> v;
v.push_back({std::move(a)}); // no warning
}

https://godbolt.org/z/4jrj1M6hY
With C++20, `v.emplace_back(std::move(a));` should be used.
</details>

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

No branches or pull requests

3 participants