From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 14981385EC56; Mon, 16 Nov 2020 16:17:58 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 14981385EC56 From: "ibuclaw at gdcproject dot org" To: gcc-bugs@gcc.gnu.org Subject: [Bug d/97843] Bad code gen when concatenating to array Date: Mon, 16 Nov 2020 16:17:57 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: d X-Bugzilla-Version: 10.2.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: ibuclaw at gdcproject dot org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: ibuclaw at gdcproject dot org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 16 Nov 2020 16:17:58 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D97843 --- Comment #5 from Iain Buclaw --- (In reply to Alex from comment #2) > The arithmetic equivalent would be for: > X +=3D 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 >=20 > 10.2.3 Binary expressions EXCEPT for AssignExpression are left to right >=20 > 10.2.7 says operand order is undefined >=20 > Nowhere does the spec say that the assignment operator has to happen after > operand evaluation. I think this is a hole in the spec. The equivalent code that `bytes ~=3D bytes.sum` equates to is: ref ubyte[] extend(ref ubyte[] bytes) { bytes.length +=3D 1; bytes[$-1] =3D 0xde; return bytes; } extend(bytes)[bytes.length] =3D bytes.sum; Which is also LTR evaluation, so everything is consistent so far.=