Look at this simple function call:
f(a(), b());
According to the standard, call order of a()
and b()
is unspecified. C++17 has the additional rule which doesn't allow a()
and b()
to be interleaved. Before C++17, there was no such rule, as far as I know.
Now, look at this simple code:
int v = 0;
int fn() {
int t = v+1;
v = t;
return 0;
}
void foo(int, int) { }
int main() {
foo(fn(), fn());
}
With C++17 rules, v
surely will have the value of 2
after the call of foo
. But, it makes me wonder, with pre-C++17, is the same guaranteed? Or could it be that v
ends up 1
? Does it make a difference, if instead of int t = v+1; v = t;
, we just have v++
?
Aucun commentaire:
Enregistrer un commentaire