public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: AJ D <aatsnps@gmail.com>
To: David Brown <david.brown@hesbynett.no>
Cc: Andreas Schwab <schwab@linux-m68k.org>, gcc@gcc.gnu.org
Subject: Re: Comma Operator - Left to Right Associativity
Date: Thu, 4 Feb 2021 14:51:22 -0800	[thread overview]
Message-ID: <CAJMvVjYegXhw3ZP=ucwy+0yLrGn8P0hiFC77dawQngy4v0oZ2g@mail.gmail.com> (raw)
In-Reply-To: <CAJMvVjaSU11mYHrcQDcprtneow0-zF-pUyxgGEh=9+vbjerLng@mail.gmail.com>

Yes, there is only function argument which is the result of the comma
operator.

On Thu, Feb 4, 2021 at 2:46 PM AJ D <aatsnps@gmail.com> wrote:

> Nope, -std=c++17 didn’t help either.
>
> On Thu, Feb 4, 2021 at 1:33 PM David Brown <david.brown@hesbynett.no>
> wrote:
>
>>
>>
>> On 04/02/2021 22:21, Andreas Schwab wrote:
>> > On Feb 04 2021, David Brown wrote:
>> >
>> >> For the built-in comma operator, you get guaranteed order of evaluation
>> >> (or more precisely, guaranteed order of visible side-effects).  But for
>> >> a user-defined comma operator, you do not - until C++17, which has
>> >> guaranteed evaluation ordering in some circumstances.
>> >
>> > But not the evaluation order of function arguments.  See
>> > <https://en.cppreference.com/w/cpp/language/eval_order>
>> Sequenced-before
>> > rules, rule 15.
>>
>> Correct.
>>
>> >
>> >> Try your test again with "-std=c++17" or "-std=g++17" - if the order is
>> >> still reversed, it's a gcc bug (AFAICS).
>> >
>> > I don't think so.
>> >
>>
>> Unless I am missing something, in the OP's program it is a user-defined
>> comma operator that is called.  There is only one argument to the
>> "test_comma_operator" function, the result of that user-defined comma
>> operator.  So rule 15 above does not apply - rule 16 applies.
>>
>> At least that is /my/ reading of the cppreference page and the OP's
>> program.
>>
>> David
>>
>>

      reply	other threads:[~2021-02-04 22:51 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-04 20:08 AJ D
2021-02-04 20:58 ` David Brown
2021-02-04 21:21   ` Andreas Schwab
2021-02-04 21:33     ` David Brown
2021-02-04 22:46       ` AJ D
2021-02-04 22:51         ` AJ D [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAJMvVjYegXhw3ZP=ucwy+0yLrGn8P0hiFC77dawQngy4v0oZ2g@mail.gmail.com' \
    --to=aatsnps@gmail.com \
    --cc=david.brown@hesbynett.no \
    --cc=gcc@gcc.gnu.org \
    --cc=schwab@linux-m68k.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).