Tighten expression sequencing

67 views
Skip to first unread message

DeadMG

unread,
Dec 9, 2012, 5:29:38 AM12/9/12
to std-pr...@isocpp.org
I'd like to suggest changes to the Standard for the purpose of tighter expression sequencing. Namely,

Firstly, each expression would be fully evaluated in it's own right before evaluating other expressions- that is, the compiler no longer has the right to interleave them. This would make unspecified many things which are currently undefined behaviour.
Secondly, the compiler is obliged to evaluate them in the order they are parsed according to the grammar- that is, left-associative expressions are parsed left-associative, function arguments from left to right, assignments right to left.

Christof Meerwald

unread,
Dec 9, 2012, 5:53:14 AM12/9/12
to std-pr...@isocpp.org
On Sun, Dec 09, 2012 at 02:29:38AM -0800, DeadMG wrote:
> I'd like to suggest changes to the Standard for the purpose of tighter
> expression sequencing. Namely,

Wouldn't that have a significant performance impact as the compiler
will be prevented from doing many useful optimisations?


Christof

--

http://cmeerw.org sip:cmeerw at cmeerw.org
mailto:cmeerw at cmeerw.org xmpp:cmeerw at cmeerw.org

Chris Jefferson

unread,
Dec 9, 2012, 8:30:47 AM12/9/12
to std-pr...@isocpp.org
On 09/12/12 10:53, Christof Meerwald wrote:
> On Sun, Dec 09, 2012 at 02:29:38AM -0800, DeadMG wrote:
>> I'd like to suggest changes to the Standard for the purpose of tighter
>> expression sequencing. Namely,
> Wouldn't that have a significant performance impact as the compiler
> will be prevented from doing many useful optimisations?

This is indeed the usual argument for not tightening up this area. I
would love to see a document by a compiler author, preferably with
experiments, showing if these features really are providing useful
performance gains.

Without concrete numbers, this suggestion will I am sure (unfortunately)
go nowhere.

Chris

Jens Maurer

unread,
Dec 9, 2012, 10:09:35 AM12/9/12
to std-pr...@isocpp.org
The current sequencing rules in the C++ standard have 20+ years
of heritage from C. If you consider writing up a proposal for such a
change, please do include results of performance experiments obtained
by modifying an optimizing compiler to observe these restrictions, also
considering various calling conventions.

Unless you're prepared to do that, such a proposal is a non-starter.

Jens

Marc

unread,
Dec 9, 2012, 10:46:27 AM12/9/12
to std-pr...@isocpp.org

A bit different: I'd like default function arguments to be able to refer to other function arguments. This is related in that it would force a sequencing at least between the evaluation of the default argument and the evaluation of those arguments it references. In this particular case, there is no performance to lose. And it can be seen as a first step into sequencing more strictly.
Reply all
Reply to author
Forward
0 new messages