Undoc'd Feature?
|
07-13-2022, 10:12 PM
(This post was last modified: 07-13-2022 10:32 PM by ijabbott.)
Post: #36
|
|||
|
|||
RE: Undoc'd Feature?
(07-12-2022 01:49 PM)Wes Loewer Wrote:(07-11-2022 07:49 PM)ijabbott Wrote: Not really. For `i = i++ + 1;`, the `i++` part says that the old value of `i` plus 1 will be be stored in `i`, and the `i = i + 1` part also says that the old value of `i` plus 1 will be stored in `i`, so there is no conflict (in C++17, but undefined in C17). EDIT: IGNORE THE FOLLOWING - IT IS WRONG (see my post just above this one) At some point 7 is stored in `i` and at some other point `i` is modified by adding 1 to it. Those two points are unsequenced relative to each other so the behaviour is undefined. Maybe `i` is incremented to 6 before 7 is stored in `i`, or maybe 7 is stored in `i` before `i` is incremented to 8, or (since the behaviour is undefined) maybe 7 is stored in `i` before 1 is added to the old value (5) of `i` and stored in `i`. — Ian Abbott |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 5 Guest(s)