448,824 Members | 1,563 Online
Need help? Post your question and get tips & solutions from a community of 448,824 IT Pros & Developers. It's quick & easy.

# precedence, sequence point, side effect

 P: n/a After browsing though many newsgroups articels I'm still not shure how operator precedence, operator associativity, sequence points, side effects go together. Currently I have the following view: An expression a = b() + c() * d++; can be transformed with the rules of operator associativity and operator precedence into a tree -> store in d ----> store in a | | d -> ++ --> * --> + --> = --> ( discard ) ^ ^ | | c -> () ----- | | | b -> () ----------- This tree ( and thus operator precedence and operator associativity ) define demonstrativly the order in which some operators are executed ( for example ++ is executed befor *, which is executed befor + ) but not of all. For example the function call operators c() and b() can be called in any order, however c() before * and b() befor +. Side effects are any computation of an operator which is not used to compute its result (on which other operators depend, i.e. parent nodes in the tree). For example n++ computes the result n, but as a side effect it stores n+1 in n. Or n=1 has the result 1, but as side effect it stores 1 in n. As can be viewn demonstrativly in the tree, side effects can be executed anywhere between after their operator has been executed and the sequence point, since they have no operations depending on them. Now sequence points define subtrees of a tree. Before the result of such a subtree (that is the result of the root node) can be used, all operations (i.e. nodes) of this subtree must have been completed. Is this view about correct? Jul 22 '05 #1