[cfe-commits] patch: add cc1 flag to reverse order of evaluation

John McCall rjmccall at apple.com
Mon Jan 14 22:07:12 PST 2013


On Jan 14, 2013, at 2:56 PM, Nick Lewycky <nlewycky at google.com> wrote:
> On 14 January 2013 14:52, Nick Lewycky <nlewycky at google.com> wrote:
> This patch adds the -reverse-order flag which reverses the order of evaluation of simple (non-complex non-aggregate) assignment expressions (eg., "a() = b();" where a() returns int& and b() returns int). The idea is to provide a debugging tool that we can use to identify bugs in user code caused by order of evaluation problems. As a starting point, I've only reversed one such evaluation (one that causes me much grief), but I'd also like to change the order of function parameter evaluation. Others may be added on an as-needed basis.

This is an interesting idea, but I'm pretty worried about it.  I understand
that this isn't your intent, but in effect you *are* talking about
implementing a knob that can be tweaked by users (even if it's an internal
option that we don't document and never claim to support) in order to force
a particular evaluation order on the compiler.  Especially when you're
talking about extending it to (accidentally, no doubt!) exactly match GCC's
argument evaluation.

Basically, it sounds an awful lot like something that some understaffed
porting effort or over-conservative platform maintainer will eventually
make us regret ever implementing.

Is there some way you can achieve your goal that doesn't leave us
vulnerable to that?

John.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130114/a660d6ea/attachment.html>


More information about the cfe-commits mailing list