[cfe-dev] operator==, Changing order of evaluation to expose bugs
Nick Lewycky via cfe-dev
cfe-dev at lists.llvm.org
Sat Oct 10 15:00:30 PDT 2015
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()'.
>
> On Oct 10, 2015 11:46 AM, "Sergio Martins via cfe-dev"
> <cfe-dev at lists.llvm.org <mailto: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 <mailto:cfe-dev at lists.llvm.org>
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
>
More information about the cfe-dev
mailing list