public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "cvs-commit at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug d/97843] Bad code gen when concatenating to array
Date: Wed, 18 Nov 2020 10:32:48 +0000	[thread overview]
Message-ID: <bug-97843-4-YvLmtCrDGr@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 #7 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-10 branch has been updated by Iain Buclaw
<ibuclaw@gcc.gnu.org>:

https://gcc.gnu.org/g:bbb887834d78cf6a444bf9cecc29d14b4dfb9cf8

commit r10-9043-gbbb887834d78cf6a444bf9cecc29d14b4dfb9cf8
Author: Iain Buclaw <ibuclaw@gdcproject.org>
Date:   Tue Nov 17 13:11:33 2020 +0100

    d: Fix LHS of array concatentation evaluated before the RHS.

    In an array append expression:

        array ~= fun(array);

    The array in the left hand side of the expression was extended before
    evaluating the result of the right hand side, which resulted in the
    newly uninitialized array index being used before set.

    This fixes that so that the result of the right hand side is always
    saved in a reusable temporary before assigning to the destination.

    gcc/d/ChangeLog:

            PR d/97843
            * d-codegen.cc (build_assign): Evaluate TARGET_EXPR before use in
            the right hand side of an assignment.
            * expr.cc (ExprVisitor::visit (CatAssignExp *)): Force a
TARGET_EXPR
            on the element to append if it is a CALL_EXPR.

    gcc/testsuite/ChangeLog:

            PR d/97843
            * gdc.dg/pr97843.d: New test.

    (cherry picked from commit 798bdfa0ebcf2bd012ffce75a594f783a8cb2dd0)

  parent reply	other threads:[~2020-11-18 10:32 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
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 [this message]
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-YvLmtCrDGr@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: link
Be 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).