comp.lang.c
[Top] [All Lists]

Re: Implementation-defined behaviour

Subject: Re: Implementation-defined behaviour
From: Richard Heathfield
Date: Fri, 28 Mar 2008 08:02:22 +0000
Newsgroups: comp.lang.c

Dann Corbit said:

<snip>
> 
> How about:
> printf("%d %d\n", ++n, n);
> 
> In this case one could possibly argue that the intent is to determine the
> modified value.

The intent might be. Nevertheless, the *purpose* is not (because the order 
of evaluation of function arguments is unspecified).

> While I agree it is an awful construct, I think that 'purpose' renders
> the statement a bit ambiguous, because it implies intent.

I don't think so, actually. Intent implies the possibility of mistaken 
execution of that intent, which would in turn require the implementation 
to read minds! No: *irrespective* of the intent, the *purpose* cannot be 
to determine the modified value, in either the "%d %d\n", ++n, n or the 
"%d %d\n", n, ++n case, because in neither case is the evaluation order 
specified.

-- 
Richard Heathfield <http://www.cpax.org.uk>
Email: -                                www">http://www. +rjh@
Google users: <                                www.cpax.org.uk/prg/writings/googly.php">http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999

<Prev in Thread] Current Thread [Next in Thread>
Privacy Policy