Aseem Rane forced the electrons to say:
> if i is initialized to say 3,
> what will be the value of j, where
> j = ++i * ++i * ++i;
> on solaris
> using cc answer is
> j = 6 * 6 * 6;
> useing gcc answer is
> j = 4 * 5 * 6;
> but on linux (RH6.1 PCQ)
> j = 5 * 5 * 6;
> can anybody explain logic behind j's value on linux???
> bye
> aseem
And can you explain the logic behind the value of j anywhere else?
Basically, C allows an lvalue to be modified only once between two
sequence points. If a program tries to do this more than once, the
results are implementation defined. This is the reason for the
differences in the value of j on the three platforms you tested.
Binand
--------------------------------------------------------------------
The Linux India Mailing List Archives are now available. Please search
the archive at http://lists.linux-india.org/ before posting your question
to avoid repetition and save bandwidth.