Undoc'd Feature?
|
07-08-2022, 05:00 AM
Post: #19
|
|||
|
|||
RE: Undoc'd Feature?
(07-08-2022 03:15 AM)jte Wrote: If one were to add a single character to the first line of the C++ code below, one would enter the land of undefined behaviour for versions of C++ before C++17: Since it's only one character, I'm guessing it has something to do with making b a reference to a Code: int a = 0, &b = a; I could see this potentially causing a problem with Code: b=a++; This could be interpreted as either 1) evaluate a (5) 2) assign that value to a (since b refers to a) (a=5) 3) increment a, making a (and b) 6 or interpreted as 1) evaluate a (5) 2) increment a (a is now 6) 3) assigned the value in step 1 to a, so a is back to 5 again. Am I on the right track? |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)