Hi there,
Might sound quite obvoius, but where can I get hold of C FAQ?
Thanks,
-Siddharth
>From: "Pramode.C.E" <[EMAIL PROTECTED]>
>Reply-To: [EMAIL PROTECTED]
>To: [EMAIL PROTECTED]
>Subject: Re: [LI] j = ++i * ++i * ++i
>Date: Tue, 18 Jan 2000 13:35:12 +0400 (SCT)
>
>
>
>On Tue, 18 Jan 2000, Aseem Rane wrote:
>
> >
> > 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???
> >
> Please refer C FAQ (i think questions 3.3,3.4 etc dealing
> with sequence points). K&R pp 52, 53, 54 is also relevant.
> Finally, you should try running some sort of lint on your
> code. You might try LCLint which is available from
> http://lclint.cs.virginia.edu/ftp/lclint/lclint-2.4b.src.tar.gz.
> Here is what lclint tells me about the code above:
>
> "Expression has undefined behaviour (left operand uses
> i, modified by right operand): ++i * ++i.
> Code has unspecified behaviour. Order of evaluation of
> function parameters or subexpressions is not defined, so
> if a value is used and modified in different places not
> separated by a sequence point constraining evaluation
> order, the result of the expression is unspecified."
>
> bye,
> pramode.
>
>
> > bye
> > aseem
> >
> >
> >
> > --------------------------------------------------------------------
> > 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.
> >
>
>--------------------------------------------------------------------
>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.
______________________________________________________
Get Your Private, Free Email at http://www.hotmail.com
--------------------------------------------------------------------
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.