lkml.org 
[lkml]   [1998]   [May]   [20]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: 'C' Operators precedence
On Wed, May 20, 1998 at 09:22:47AM -0400, Richard B. Johnson wrote:
> Read a text like:
> C:Step-by-Step, Waite & Prata, The White Group, Howard W Sams Publ.
> ISBM 0-672-22651-0

I've read H&S, 2nd and 4th editions, and both the left and right pages
in the Annotated Standard. I have no need to read the book you cite;
I would suggest you read the left-hand pages in the Annotated Standard,
though. Please don't read the right hand pages, though; your
understanding of the () operator, the difference between parsing and
evaluation, and sequence points is muddy enough already.

My copy of the Standard has unfortunately grown legs and walked away.
Others have posted the chapter and verse though.


There is a sequence point defined by the () operator (which is the
function-call operator ONLY, not "any use of parentheses). The
expressions inside the parentheses are evaluated before the function call
is evaluated; there is a sequence point there. The commas separating
arguments to the function are not the , operator, and thus don't generate
sequence points of their own. Furthermore, a strong case has been made
that, in an expression involving multiple function calls, no ordering is
defined between the evaluation of operands to one of the functions and
either evaluation fo the operands of others or call to the others.
That is, "a + f(a=1) + f(a=2)" is undefined, as 'a' is set twice without
there necessarily being a sequence point between the settings; some
well-respected readers of the standard go further and say that in "a +
f(1) + f(2)", the two calls to 'f' may run simultaneously, with no
sequence point necessarily between the execution of the bodies of the two
calls.

If you won't read the standard, at least read the comp.lang.c FAQ.


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu

\
 
 \ /
  Last update: 2005-03-22 13:42    [from the cache]
©2003-2014 Jasper Spaans. Advertise on this site