This is the mail archive of the
mailing list for the GCC project.
Re: C++ order of evaluation of operands, arguments
- From: Martin Sebor <msebor at gmail dot com>
- To: Jason Merrill <jason at redhat dot com>, GCC <gcc at gcc dot gnu dot org>
- Date: Tue, 24 Nov 2015 07:59:20 -0700
- Subject: Re: C++ order of evaluation of operands, arguments
- Authentication-results: sourceware.org; auth=none
- References: <56539AD0 dot 80905 at redhat dot com>
On 11/23/2015 04:01 PM, Jason Merrill wrote:
There's a proposal working through the C++ committee to define the order
of evaluation of subexpressions that previously had unspecified ordering:
I agree with much of this, but was concerned about the proposal to
define order of evaluation of function arguments as left-to-right, since
GCC does right-to-left on PUSH_ARGS_REVERSED targets, including x86_64.
I have no comments on the impact on the implementation but I do
have a couple of general concerns with the proposal.
As others have already suggested, I think a change like this needs
to be coordinated with WG14 and made either in both languages or
in neither. If C++ were to make it alone, C++ programmers who only
occasionally write C code would be prone to introducing bugs into
their C code by relying on the C++ guarantees. As WG14 is just
starting to talk about the goals for C2x, this seems like a good
time to bring it up for consideration.
Even in C++, though, I'd worry that specifying the evaluation order
for just a subset of expression would lead to portability bugs
creeping in as programmers inadvertently start to assume that
the same order is guaranteed for all expressions.