public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "jakub at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/97278] increment or decrement operator on the same object Date: Sat, 03 Oct 2020 08:32:00 +0000 [thread overview] Message-ID: <bug-97278-4-cmuZCIG4PP@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-97278-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97278 Jakub Jelinek <jakub at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |RESOLVED Resolution|--- |INVALID CC| |jakub at gcc dot gnu.org --- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> --- Your testcase is invalid, even C++17 and later, therefore you can get any result. While C++17 added some extra evaluation ordering rules over earlier C++ revisions, for calls, i.e. postfix-expression ( expression-list_opt_ ) the standard now says: The postfix-expression is sequenced before each expression in the expression-list and any default argument. The initialization of a parameter, including every associated value computation and side effect, is indeterminately sequenced with respect to that of any other parameter. [Note: All side effects of argument evaluations are sequenced before the function is entered (see 6.9.1). — end note] so while side-effects in the postfix-expression need to be evaluated before the arguments, there is no sequence point between the arguments. g++ even warns about this with -Wall: pr92278.C: In function ‘int main()’: pr92278.C:9:42: warning: operation on ‘i’ may be undefined [-Wsequence-point] 9 | __builtin_printf ("%d\n", func(++i, i++)); | ~^~ pr92278.C:9:42: warning: operation on ‘i’ may be undefined [-Wsequence-point]
prev parent reply other threads:[~2020-10-03 8:32 UTC|newest] Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-10-03 6:43 [Bug c++/97278] New: " tangyixuan at mail dot dlut.edu.cn 2020-10-03 8:32 ` jakub at gcc dot gnu.org [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=bug-97278-4-cmuZCIG4PP@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.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: linkBe 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).