zagadka - postinkrementacja
Ostatnio zmodyfikowano 2018-04-03 00:43
pekfos |
» 2018-04-03 00:43:52 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#637It should be noted that a similar expression i = i++ + 1; is still not well-defined, since the incrementation side-effect remains unsequenced with respect to the assignment side-effect. [..] i = i++ + 1; // the behavior is undefined |
Taki zapis miał niezdefiniowane zachowanie, ale najwyraźniej już nie ma. //edit: http://en.cppreference.com/w/cpp/language/eval_order20) In every simple assignment expression E1=E2 and every compound assignment expression E1@=E2, every value computation and side-effect of E2 is sequenced before every value computation and side effect of E1 (since C++17) |
Przed C++17 ten zapis miał niezdefiniowane zachowanie, od 17 jest poprawny. |
|
1 « 2 » |