[Subject Prev][Subject Next][Thread Prev][Thread Next][Subject Index][Thread Index]

[LI] j = ++i * ++i * ++i



The value is undefined as per the C specifications, so each compiler
is free to return whatever result it feels like.  You'll probably get
even more variant results if you compile with/without optimisation
and/or put i in a register.

Regards,

-- Raju

>>>>> "Aseem" == Aseem Rane <aseem@xxxxxxxxxxxxxxxx> writes:

    Aseem> if i is initialized to say 3,

    Aseem> what will be the value of j, where

    Aseem> j = ++i * ++i * ++i;

    Aseem> on solaris using cc answer is j = 6 * 6 * 6;

    Aseem> useing gcc answer is j = 4 * 5 * 6;


    Aseem> but on linux (RH6.1 PCQ)

    Aseem> j = 5 * 5 * 6;

    Aseem> can anybody explain logic behind j's value on linux???

    Aseem> bye aseem



    Aseem> --------------------------------------------------------------------
    Aseem> The Linux India Mailing List Archives are now available.
    Aseem> Please search the archive at http://lists.linux-india.org/
    Aseem> before posting your question to avoid repetition and save
    Aseem> bandwidth.

--------------------------------------------------------------------
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.