initialization
Chris Torek
chris at mimsy.umd.edu
Thu Aug 2 19:45:47 AEST 1990
In article <11221 at odin.corp.sgi.com> jindak at surfside.sgi.com
(Chris Schoeneman) writes:
(re the code `f(int a) { int i = a, j = i + 1;')
>... don't worry, the comma operator is evaluated left to right. So your
>code will always work correctly (i.e. "a" will be assigned to "i", then
>"i"+1 will be assigned to "j").
Strictly speaking, the comma in
int i = a, j = i + 1;
is not a comma operator. Nonetheless the ANSI C standard guarantees
that, after the sequence point at the semicolon, `i' will have the
value `a' has and `j' will have the result of `a + 1' (since i==a, i+1
has the same effect as a+1, including such things as runtime traps, at
least if overflow is `implementation defined' [I cannot remember
whether this is in fact the case]).
--
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163)
Domain: chris at cs.umd.edu Path: uunet!mimsy!chris
More information about the Comp.lang.c
mailing list