C++ Evaluation Order

Gabriel Dos Reis gdr@codesourcery.com
Tue Dec 19 17:12:00 GMT 2000

"Marc A. Lepage" <mlepage@molecularmining.com> writes:


| My understanding is that pFoo->getIdentifier() should be called before
| pFoo.release(). 

I disagree with that understanding.

The Standard says 5/4:
  Except where noted, the order of evaluation of operands of
  individual operators and subexpressions of individual expressions,
  and the order in which side effects take place, is unspecified. [...] 

Furthermore, 5.2.2/8 says:

  [...] The order of evaluation of the postfix expression and the
  argument expression list is unpecified.

So it appears that GCC's behaviour is permitted and the problem is
in your code relying on a particular order of evaluation.

-- Gaby
CodeSourcery, LLC                       http://www.codesourcery.com

More information about the Gcc-bugs mailing list