This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: The order of calling functions and << <<


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."


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]