Consider the following expression (with declaration for exposition):
int n = 42;
--n &= 0x01;
Does this fall foul of sequencing rules?
In my opinion, the preincrement is needed as part of the "value computation" of the left-hand operand. If this is true, there's no UB here since C++11 (and, since C++17, both value computations and side effects are sequenced relative to the assignment).
If it were a postincrement, then the modification of n
would be merely a side-effect and we'd not have good sequencing (until C++17).
Aucun commentaire:
Enregistrer un commentaire