Mail Archives: djgpp/2006/04/06/05:00:29
Brian Inglis <Brian DOT Inglis AT systematicsw DOT invalid> wrote:
> The compiler should not be rearranging the order of calls to external
> functions specified in separate statements, unless there were some
> other factors involved that it could infer.
Well --- it's not rearranging calls to external functions, since Ack()
is not exactly an external function in the example case. The only
calls to external functions are those to clock() and printf(), in that
example, and those are left in their original order. The only strange
thing is that GCC apparently detected that Ack() and clock() were
independent jobs that could be done in parallel, since the result of
one could not possibly depend on whether the other was finished yet.
So it expanded Ack() inline (at least partially), and put the call to
clock right in the middle of it.
Unfortunately, that detection is wrong for a function like clock(). I
may be going out on a limb there, but this could require a change to
the declaration of clock() and similar functions to forbid this kind
of optimization.
--
Hans-Bernhard Broeker (broeker AT physik DOT rwth-aachen DOT de)
Even if all the snow were burnt, ashes would remain.
- Raw text -