evaluation order of expressions in gcc

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



hi, all

i could not find an answer to this question on the net so i'm posting it
here.

as far as i know, the Ansi C standard does not specify the order of
evaluation of expression arguments. so if i wrote:

x = f() + g()

it would be up to the compiler whether f() or g() would be called first.

my question is, does anybody know how does the current version of gcc choose
whether to call f() or 
g() first? on which optimization options does this depend, if any? 

after making a few experiments, it looks like gcc usually does left-to-right
evaluation (first calls f() and then g()). so i would like to know in which
cases (if any) this would not be true. or if this information is not known
for the current version, then for any previous version would also be
appreciated.

to clarify: i am not interested in the evaluation order of arguments to a
function call, or left vs right side of an assigment. also i am not interested
in expressions involving pre- or post- increment or decrement or anything
such. i understand that these may be a problem. so my question is only regarding
function calls in expressions with normal arithmetic (also pointer
arithmetic) and compare operators.

laura

-- 
+++ NEU bei GMX und erstmalig in Deutschland: TÜV-geprüfter Virenschutz +++
100% Virenerkennung nach Wildlist. Infos: http://www.gmx.net/virenschutz


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux