This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: The order of calling functions and << <<
- To: jbuck at Synopsys dot COM (Joe Buck)
- Subject: Re: The order of calling functions and << <<
- From: Tim Hollebeek <tim at wagner dot princeton dot edu>
- Date: Mon, 7 Dec 1998 14:11:38 -0500 (EST)
- Cc: egcs at cygnus dot com
Joe Buck writes ...
>
> No, it is no more nasty than
>
> a[i] = i++;
>
> because it is exactly the same pitfall.
Well. Slightly different. That one is bad because it modifies an
object twice between sequence points; order of evaluation is part of
the reason for the rule, but isn't explicitly involved in the rule
that forbids this. This snippet invokes undefined behavior.
The original case isn't technically as bad since no undefined behavior
is invoked. It is "merely" a case where the result depends on the
order of evaluation, which is unspecified (*not* undefined). Hence
the program is not strictly conforming, but it still must print one of
the two results.
But I'm being pedantic. Your point stands, and further discussion
should go somewhere like comp.std.c/c++. I just thought I'd point it
out, since several people have carelessly thrown around the word
"undefined" in this thread.
---------------------------------------------------------------------------
Tim Hollebeek | "Everything above is a true
email: tim@wfn-shop.princeton.edu | statement, for sufficiently
URL: http://wfn-shop.princeton.edu/~tim | false values of true."