Path: csiph.com!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c++ Subject: Re: GCC hasn't even gotten around to sequencing argument evaluation yet??? Date: Sat, 09 Apr 2022 22:34:26 -0700 Organization: None to speak of Lines: 52 Message-ID: <87ee25o61p.fsf@nosuchdomain.example.com> References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: reader02.eternal-september.org; posting-host="135db30b784175e4173309be2d7db731"; logging-data="31493"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18r39Oxp0POZfeL99hBiopo" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) Cancel-Lock: sha1:9J5SMbZMx1jk0Q2igbk3a06lapw= sha1:jntRdVD5IEVA2nDdCO91736HwPQ= Xref: csiph.com comp.lang.c++:83556 "james...@alumni.caltech.edu" writes: > On Sunday, April 10, 2022 at 12:06:23 AM UTC-4, Christian Hanné wrote: >> Am 02.04.2022 um 05:34 schrieb Andrey Tarasevich: >> > #include >> > >> > int foo(int a, int b) >> > { >> > return a + b; >> > } >> > >> > int main() >> > { >> > int i = 1; >> > int r = foo(++i, ++i); >> > std::cout << r << std::endl; >> > } >> > >> > This outputs 6 in GCC 11.2 in `-std=c++17` mode and later. WTF? ... >> >> The ++i's are taken ordered from left to right since the >> first C version. > > Citation, please? > > My copy of the C90 standard says "The order of evaluation of the > function designator, the arguments, and subexpressions within the > arguments is unspecified, but there is a sequence point before the > actual call." (6.3.2.2). > > My copy of "The C Programming Language", 1st edition, says "The > order of evaluation of arguments is undefined by the language; take > note that the various compilers differ." Appendix A, sectiojn 7.1. > > How do your sources differ from mine? Christian Hanné's sources differ from yours in that you are not a troll. Christian Hanné has a history of posting deliberate misinformation here. It's not plausible that he's merely mistaken; his lies indicate that he knows the truth. The particular nonsense of his that landed him in my killfile a year and a half ago was: Convertion to uintptr_t involves a privilege-check to the page addressed. That's not true for conversions to ptrdiff_t or size_t. (I presume he thinks he's being clever.) -- Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com Working, but not speaking, for Philips void Void(void) { Void(); } /* The recursive call of the void */