>
> k=++j + (++j + ++j); it gives 15!
>

As explained before, here is the compiler behavior that lead to this output:

j=2
Divide the long expression into two branches: ++j AND (++j + ++j)

The first branch: j=j+1, then the result is found in j
The second branch: divide into two subbranches, ++j AND ++j

The first branch: j=3 and its result is found in j
The second branch:
   The first subbranch: j=j+1, then the result is found in j
   The second subbranch: j=j+1, then the result is found in j

The first branch: j=3 and its result is found in j
The second branch:
   The first subbranch: j=4 and its result is found in j
   The second subbranch: j=5 and its result is found in j

The first branch: j=5
The second branch: Add(The first subbranch: {j=5} , The second
subbranch:{j=5}), which gives 10

*The result:* Add(The first branch: {j=5}, 10), which gives 15



I agree, and the 'deep language specification' here is that this
> behaviour is undefined.
>

Maybe you are correct here, it's neither a bug nor as designed, it's just
undefined, which means that other behavior could be taken under different
machines, and thus different results.


-- Amahdy
www.amahdy.net



On Tue, Aug 16, 2011 at 12:09, Paul Smith <[email protected]> wrote:

> On Tue, Aug 16, 2011 at 1:03 AM, Amahdy <[email protected]> wrote:
> > I don't agree with you +Paul, one of the essential learning curves IMHO,
> is
> > to learn the compiler behavior and the deep language specifications and
> > details.
>
> I agree, and the 'deep language specification' here is that this
> behaviour is undefined.
>
> --
> You received this message because you are subscribed to the Google Groups
> "google-codejam" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/google-code?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"google-codejam" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-code?hl=en.

Reply via email to