public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "alex at sunopti dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug d/97843] Bad code gen when concatenating to array Date: Mon, 16 Nov 2020 12:16:17 +0000 [thread overview] Message-ID: <bug-97843-4-yavndwfU4g@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-97843-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97843 --- Comment #2 from Alex <alex at sunopti dot com> --- I agree that the order of evaluation of operands is undefined and writing code that depends on that order would not be reliable. In this case it's the execution of the assign expression happening before all the operands have been evaluated that is the problem. The arithmetic equivalent would be for: X += 4/2 To be produce: Immediate load Register with 4 Add register with 4 in it to x Divide register with 4 in it by 2 Resulting in x being increased by 4 instead of 2 10.2.3 Binary expressions EXCEPT for AssignExpression are left to right 10.2.7 says operand order is undefined Nowhere does the spec say that the assignment operator has to happen after operand evaluation. I think this is a hole in the spec.
next prev parent reply other threads:[~2020-11-16 12:16 UTC|newest] Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-11-16 1:11 [Bug d/97843] New: " alex at sunopti dot com 2020-11-16 11:31 ` [Bug d/97843] " ibuclaw at gdcproject dot org 2020-11-16 12:16 ` alex at sunopti dot com [this message] 2020-11-16 15:34 ` ibuclaw at gdcproject dot org 2020-11-16 15:35 ` ibuclaw at gdcproject dot org 2020-11-16 16:17 ` ibuclaw at gdcproject dot org 2020-11-16 20:56 ` alex at sunopti dot com 2020-11-18 10:32 ` cvs-commit at gcc dot gnu.org 2020-11-18 10:37 ` ibuclaw at gdcproject dot org 2020-11-18 10:38 ` ibuclaw at gdcproject dot org
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-97843-4-yavndwfU4g@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).