Undoc'd Feature?
|
07-11-2022, 07:49 PM
(This post was last modified: 07-11-2022 07:56 PM by ijabbott.)
Post: #30
|
|||
|
|||
RE: Undoc'd Feature?
(07-10-2022 07:38 PM)Wes Loewer Wrote: While the C++17 documentation has this 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). 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. That's also one reason why `i = i++ + i;` is undefined - the `i++` part says the old value of `i` plus 1 will be stored in `i`, and the `i = i + i` part says the old value of `i` plus the old value of `i` will be stored in `i`. (The other reason is that the storage to `i` by `i++` is unsequenced relative to the evaluation of `i` in the `... + i`.) — Ian Abbott |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 4 Guest(s)