Re: Benefit of not defining the order of execution
- From: Keith Thompson <kst-u@xxxxxxx>
- Date: Wed, 18 Feb 2009 09:23:03 -0800
Nate Eldredge <nate@xxxxxxxxxx> writes:
cri@xxxxxxxx (Richard Harter) writes:
On Wed, 18 Feb 2009 06:36:54 +0000, Flash Gordon
<smap@xxxxxxxxxxxxxxxxx> wrote:
Sine different people assume different orders (and some know the order
is unspecified as far as the language is concerned) forcing a specific
order on compilers will certainly still leave people getting it wrong
*and* will make some implementations less efficient. Seems like a
loose-loose option to me.
I disagree; it's not a lose-lose option. However the issue of
peoples assumptions being satisfied or not satisfied is not
particularly important. What is important, IMNSHO, is that
outputs of working conforming programs can vary depending on
evaluation order choices by compilers.
But that's just the point: programs that depend on the evaluation order
are NOT conforming.
They're not portable, but there's nothing non-conforming about
depending on evaluation order as long as you avoid undefined behavior.
If a program's output depends on unspecified evaluation order, then it
can't be *strictly* conforming, but it can certainly be conforming.
Actually, the standard's definition of "conforming program" is very
weak, but as long as any difference in behavior isn't significant to
the program's functionality, such a program can even be portable.
(Think regression tests
on log files.)
Huh?
Consider a program containing something like this:
double result = this() * that() + the_other();
Assuming that the three functions don't interact in any nasty ways
(depending on the same global variables, for example), the order of
evaluation shouldn't matter; result will get the same value for any of
the 6 possible orders. But suppose the functions contain trace
statements that (perhaps optionally) log information to a file. Then
the contents of the log can vary depending on the evaluation order,
and a testing scheme that looks for possible regressions by detecting
changes in the contents of the log will have problems.
--
Keith Thompson (The_Other_Keith) kst@xxxxxxx <http://www.ghoti.net/~kst>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
.
- Follow-Ups:
- Re: Benefit of not defining the order of execution
- From: Stephen Sprunk
- Re: Benefit of not defining the order of execution
- References:
- Benefit of not defining the order of execution
- From: somenath
- Re: Benefit of not defining the order of execution
- From: Kaz Kylheku
- Re: Benefit of not defining the order of execution
- From: Tim Rentsch
- Re: Benefit of not defining the order of execution
- From: nick_keighley_nospam
- Re: Benefit of not defining the order of execution
- From: Keith Thompson
- Re: Benefit of not defining the order of execution
- From: Richard Harter
- Re: Benefit of not defining the order of execution
- From: Flash Gordon
- Re: Benefit of not defining the order of execution
- From: Richard Harter
- Re: Benefit of not defining the order of execution
- From: Nate Eldredge
- Benefit of not defining the order of execution
- Prev by Date: Re: Benefit of not defining the order of execution
- Next by Date: Re: Logical operator not working in if condition
- Previous by thread: Re: Benefit of not defining the order of execution
- Next by thread: Re: Benefit of not defining the order of execution
- Index(es):
Relevant Pages
|