Undoc'd Feature?
|
07-13-2022, 09:34 PM
(This post was last modified: 07-13-2022 10:30 PM by ijabbott.)
Post: #35
|
|||
|
|||
RE: Undoc'd Feature?
(07-12-2022 11:03 AM)RPNerd Wrote:(07-11-2022 07:49 PM)ijabbott Wrote: However, for `i = i++;`, the `i++` part says that the old value of `i` plus 1 will be stored in `i`, and the `i = i` part says that the old value of `i` will be stored in `i`, so there is a conflict. EDIT: IGNORE THE FOLLOWING - IT IS WRONG The problem is that the two stores to `i` are unsequenced relative to each other. You are under the impression that the store caused by `++` on the r.h.s. occurs before the store caused by the `=`, but there is nothing in the standard to support that. TBH, I don't know why they bothered allowing `i = i++ + 1;` as a special case as it is a pretty pointless construct. The blanket ban in the earlier version is easier to understand, IMHO. EDIT: CORRECTION FOLLOWS I missed the sentence added to C++17 for the assignment operators that reads as follows Quote:The right operand is sequenced before the left operand. That little sentence makes all the difference! — Ian Abbott |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 4 Guest(s)