From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from asav21.altibox.net (asav21.altibox.net [109.247.116.8]) by sourceware.org (Postfix) with ESMTPS id 4030A3857023 for ; Thu, 4 Feb 2021 21:33:20 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 4030A3857023 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=hesbynett.no Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=david.brown@hesbynett.no Received: from mail.jansenbrown.no (unknown [92.221.34.247]) by asav21.altibox.net (Postfix) with ESMTP id E07A480180; Thu, 4 Feb 2021 22:33:18 +0100 (CET) Received: from [192.168.4.227] (unicorn.lan [192.168.4.227]) by mail.jansenbrown.no (Postfix) with ESMTPSA id 14E4221547B; Thu, 4 Feb 2021 22:33:18 +0100 (CET) Subject: Re: Comma Operator - Left to Right Associativity To: Andreas Schwab Cc: AJ D , gcc@gcc.gnu.org References: <59add9a1-ef9b-1cde-a4b7-66a167595a6b@hesbynett.no> <87v9b7v8a9.fsf@igel.home> From: David Brown Message-ID: Date: Thu, 4 Feb 2021 22:33:18 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <87v9b7v8a9.fsf@igel.home> Content-Type: text/plain; charset=utf-8 Content-Language: en-GB Content-Transfer-Encoding: 7bit X-CMAE-Score: 0 X-CMAE-Analysis: v=2.3 cv=Kb38TzQD c=1 sm=1 tr=0 a=+Fy6h7hJ4UJcWgHwdIx3jg==:117 a=+Fy6h7hJ4UJcWgHwdIx3jg==:17 a=IkcTkHD0fZMA:10 a=qa6Q16uM49sA:10 a=2QSLavsyAAAA:8 a=BDhgk7oY7yLKKsNZc4AA:9 a=QEXdDO2ut3YA:10 a=9H_80fVQ3bbXSWzY4Kdq:22 X-Spam-Status: No, score=-7.2 required=5.0 tests=BAYES_00, JMQ_SPF_NEUTRAL, KAM_DMARC_STATUS, NICE_REPLY_A, SPF_HELO_NONE, SPF_NEUTRAL, TXREP autolearn=no autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 04 Feb 2021 21:33:21 -0000 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 > 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