[cfe-dev] operator==, Changing order of evaluation to expose bugs

Richard Smith via cfe-dev cfe-dev at lists.llvm.org
Sat Oct 10 11:47:41 PDT 2015


Nick, did you ever put together a patch for this?
On Oct 10, 2015 11:46 AM, "Sergio Martins via cfe-dev" <
cfe-dev at lists.llvm.org> wrote:

> 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
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20151010/ff60f49d/attachment.html>


More information about the cfe-dev mailing list