I am using the intel c++ compiler icc version 18.0.3.
If I compile the following code with -w3
#include <vector>
int main() {
std::vector<int> vec;
vec.push_back(2);
return 0;
}
test_w3.cpp(6): remark #383: value copied to temporary, reference to temporary used vec.push_back(2);
Replacing the 2
with a const variable as
#include <vector>
int main() {
std::vector<int> vec;
const int a = 2;
vec.push_back(a);
return 0;
}
does not give a warning.
What does this warning mean? Can it safely be ignored (although warning free code is desirable)?