|
|
"Richard Heathfield" <rjh@xxxxxxxxxxxxxxx> wrote in message
news:ec2dnW7ZxYEwBnHanZ2dnUVZ8tfinZ2d@xxxxxxxxx
> Dann Corbit said:
>
>> "Barry Schwarz" <schwarzb@xxxxxxxx> wrote in message
>> news:c80pu39ghqdnumqju6mk2qgktt751hb7bn@xxxxxxxxxx
> <snip>
>>>> printf("%d %d\n", n++, n);
>>>>foo.c(8) : Warning 564: variable 'n' depends on order of evaluation
>>>
>>> The correct diagnostic would state: without an intervening sequence
>>> point, n is modified and also evaluated for a purpose other than
>>> determining the modified value. This invokes undefined behavior.
>>
>> The examination of n in the last parameter of printf() is to determine
>> its value.
>
> More to the point, it is /not/ to determine the /modified/ value.
How about:
printf("%d %d\n", ++n, n);
In this case one could possibly argue that the intent is to determine the
modified value.
>> I am not sure that your interpretation is certain. Are you sure of it?
>
> If he isn't, he should be.
While I agree it is an awful construct, I think that 'purpose' renders the
statement a bit ambiguous, because it implies intent.
--
Posted via a free Usenet account from http://www.teranews.com
|
|