operator==, Changing order of evaluation to expose bugs

Hi,

Consider:
if (foo() == bar())

it's up to the compiler to decide if it calls foo() or bar() first, as the
standard doesn't guarantee any order.

Is there a way to force clang to evaluate first the rhs ?

I want to compile Qt with "evaluate rhs first" and check that unit-tests still
pass, then rebuild with "evaluate lhs first".

Recenty we found some Qt code that relied on the order (undefined behavior)
and it was discovered by compiling the code with MSVC2010, which evaluated the
rhs first.

Regards,
Sérgio Martins

Nick, did you ever put together a patch for this?

Richard Smith wrote:

Nick, did you ever put together a patch for this?

The work I did ended up here:

http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of-Mon-20130114/071817.html

I don't think I ever reversed the order of 'foo() == bar()'.