In article <m3************ @localhost.loca ldomain>,
Micah Cowan <mi***@cowan.na me> wrote:
Jeremy Yallop <je****@jdyallo p.freeserve.co. uk> writes:
sugaray wrote: > does the expression int a=printf("%d\n" ,a); implementation dependent ?
No, it's undefined, since `a' hasn't been initialized at the time you
pass its value to printf(). Don't do that.
How do you know that? He gave us an isolated expression: there is
no way to know whether or not it was initialized.
Assuming it was, it is uncertain to me whether the expression
above meets the requirement in 6.5#2 that "the prior value shall
be read only to determine the value to be stored." (the exact
meaning and intent of that phrase is somewhat unclear to me).
I'm not sure that requrement is even relevant here; doesn't that
only apply between sequence points? There's a sequence point between
evaluating a in the argument list and the invocation of printf, and
another one immediately after printf returns before its return value is
assigned to a, so there's no problem between the access and modification
of a.
dave
--
Dave Vandervies
dj******@csclub .uwaterloo.ca
If he'd got it wrong (and it happens to us all), several people would
have jumped on him and started stuffing socks down his throat.
--Richard Heathfield in comp.lang.c