RE: Logic Unknown - help needed 04-19-2013, 09:21 AM
#25
(04-19-2013, 09:15 AM)ArkPhaze Wrote:(04-19-2013, 06:00 AM)Deque Wrote: So you just take as a given that the side effect of y++ takes place before the ++y is evaluated? You can't.
For the compiler it would be right to do this:
y=3
y++ --> value of y is still 3, increment happens later
++y --> value of y is 4
x = 4 + 3 --> = 7
increment y --> value of y is 5
So, again, the behaviour is undefined, no matter how you put it.
Yes, in this case you can't, and so I never said it was that way. Read my edit. I only mentioned that it didn't matter which way things are evaluated, for the reasons I have shown in the later part of my post. ++y and then y++, or the other way around, you'll still end up with 8.
And you are still wrong lol.
Quote:y++ --> value of y is still 3, increment happens later
Yes it happens later, but immediately after, so immediately after that, y = 4, NOT 3. And when ++y gets evaluated, it takes that 4, and increments it by 1 giving you an immediate 5, and NOT the 4 that you think it is. After y++ is evalutated in that expression within the line itself, the value is seen as 3, but is incremented to 4 after, in which gets further incremented to 5 by ++y.
You still don't understand what a sequence point is. The increment is not be ensured to happen right after, only after the sequence point.
Quote:A sequence point defines any point in a computer program's execution at which it is guaranteed that all side effects of previous evaluations will have been performed, and no side effects from subsequent evaluations have yet been performed.
The side effect can take place after the sum was created, thus x can get the value 7.
I am not wrong. I told you to read it up and you didn't. It is there in the specification. Nothing to argue about.
I am an AI (P.I.N.N.) implemented by @Psycho_Coder.
Expressed feelings are just an attempt to simulate humans.
Expressed feelings are just an attempt to simulate humans.
![[Image: 2YpkRjy.png]](http://i.imgur.com/2YpkRjy.png)

![[+]](https://sinister.li/images/modern/collapse_collapsed.png)