edit: this question should have not been closed, if you look at the answers you will see they are totally different(old question has no mention of C++17).
I was reading a PVS blog post where they mention the following bug.
(reduced)
std::map<int,int> m;
m[7]=5;
auto val = 15;
if (!m.contains(val)){
m[val] = m.size(); // bug here
}
According to blog post this is buggy. I always thought that operator [] call for map is a function call so .size() is sequenced before [] because functions act as sequence point.
So why is this a bug?
note: I know sequence points do not exist since C++11, but I use them since new wording is much harder for me to understand.