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 c++/94219] ICE in cxx_eval_bare_aggregate, at cp/constexpr.c:3790
Date: Sat, 04 Apr 2020 16:18:02 +0000	[thread overview]
Message-ID: <bug-94219-4-i8bK6R1hCs@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-94219-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94219

--- Comment #2 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Patrick Palka <ppalka@gcc.gnu.org>:

https://gcc.gnu.org/g:37244b217a7329792f4ec48027f63cf5010b0ea8

commit r10-7556-g37244b217a7329792f4ec48027f63cf5010b0ea8
Author: Patrick Palka <ppalka@redhat.com>
Date:   Thu Apr 2 12:59:34 2020 -0400

    c++: Fix constexpr evaluation of self-modifying CONSTRUCTORs [PR94219]

    This PR reveals that cxx_eval_bare_aggregate and cxx_eval_store_expression
do
    not anticipate that a constructor element's initializer could mutate the
    underlying CONSTRUCTOR.  Evaluation of the initializer could add new
elements to
    the underlying CONSTRUCTOR, thereby potentially invalidating any pointers
to
    or assumptions about the CONSTRUCTOR's elements, and so these routines
should be
    prepared for that.

    To fix this problem, this patch makes cxx_eval_bare_aggregate and
    cxx_eval_store_expression recompute the constructor_elt pointers through
which
    we're assigning, after it evaluates the initializer.  Care is taken to to
not
    slow down the common case where the initializer does not modify the
underlying
    CONSTRUCTOR.

    gcc/cp/ChangeLog:

            PR c++/94219
            PR c++/94205
            * constexpr.c (get_or_insert_ctor_field): Split out (while adding
            support for VECTOR_TYPEs, and optimizations for the common case)
            from ...
            (cxx_eval_store_expression): ... here.  Rename local variable
            'changed_active_union_member_p' to 'activated_union_member_p'. 
Record
            the sequence of indexes into 'indexes' that yields the subobject
we're
            assigning to.  Record the integer offsets of the constructor
indexes
            we're assigning through into 'index_pos_hints'.  After evaluating
the
            initializer of the store expression, recompute 'valp' using
'indexes'
            and using 'index_pos_hints' as hints.
            (cxx_eval_bare_aggregate): Tweak comments.  Use
get_or_insert_ctor_field
            to recompute the constructor_elt pointer we're assigning through
after
            evaluating each initializer.

    gcc/testsuite/ChangeLog:

            PR c++/94219
            PR c++/94205
            * g++.dg/cpp1y/constexpr-nsdmi3.C: New test.
            * g++.dg/cpp1y/constexpr-nsdmi4.C: New test.
            * g++.dg/cpp1y/constexpr-nsdmi5.C: New test.
            * g++.dg/cpp1z/lambda-this5.C: New test.

  parent reply	other threads:[~2020-04-04 16:18 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-18 22:24 [Bug c++/94219] New: " ppalka at gcc dot gnu.org
2020-03-19  8:17 ` [Bug c++/94219] " marxin at gcc dot gnu.org
2020-04-01 21:41 ` ppalka at gcc dot gnu.org
2020-04-04 16:18 ` cvs-commit at gcc dot gnu.org [this message]
2020-04-04 16:21 ` ppalka at gcc dot gnu.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-94219-4-i8bK6R1hCs@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).