Multiple Assignment Evaluation Debate



Hi All,

A coworker and I have been debating the 'correct' expectation of
evaluation for the phrase a = b = c. Two different versions of GCC
ended up compiling this as b = c; a = b and the other ended up
compiling it as a = c; b = c. (Both with no optimizations enabled).
How did we notice you may ask? Well, in our case 'b' was a memory
mapped register that only has a select number of writable bits. He
claims it has been a 'C Standard' that it will be evaluted as a = c; b
= c. I personally believe that it would make more sense for it to be
evaluated as b = c; a = b, although I would never write code that has a
questionable operation. Can anyone settle this debate?

.



Relevant Pages

  • Re: Multiple Assignment Evaluation Debate
    ... evaluation for the phrase a = b = c. ... Two different versions of GCC ... compiling it as a = c; b = c.. ... a sprinkling of the "volatile" keyword may do something ...
    (comp.lang.c)
  • Re: Multiple Assignment Evaluation Debate
    ... Two different versions of GCC ... compiling it as a = c; b = c.. ... The Standard only requires that the new values of a and b ... If you depend on the order of evaluation, any side effects of a, b, and c ...
    (comp.lang.c)
  • Re: Multiple Assignment Evaluation Debate
    ... evaluation must precede _any_ side effect, ... Two different versions of GCC ended up compiling this as ...
    (comp.lang.c)
  • Re: problem related to printf!! why is it so???
    ... >My coding is as follows ... converted to float and assigned to answer. ... to force the evaluation of the ... If you used gcc correctly, ...
    (comp.lang.c)
  • Re: Evaluation order of assignment statement
    ... with different compilers. ... Using gcc, I get 17 written in array. ... MSVC on the other hand evaluated RHS first. ... the order of function evaluation, which I understand is not defined). ...
    (comp.lang.c)