- What language is this for?
C++ - Which rule?
cpp:S6003 - Why do you believe it’s a false-positive/false-negative?
When push_back is used in conjunction with designated initializers, it is just not possible to replace the push_back call in an equivalent way with emplace_back due to C++ syntax limitations. Therefore it would make more sense not to flag this as a violation. - Are you using
- SonarQube - which version?
Enterprise Edition Version 9.9 (build 65466)
- SonarQube - which version?
- How can we reproduce the problem? Give us a self-contained snippet of code (formatted text, no screenshots)
#include <vector>
struct X {
int a;
int b;
int pad[100];
};
int main()
{
std::vector<X> vec;
vec.push_back(X{.a{1}, .b{2}});
}
Compiler Explorer (here also the quick fix is wrong - if you apply it, it won’t compile any more)