[Bug c++/94772] [10 Regression] constructing constexpr variables fail with delegated constexpr constructors

2020-04-27 Thread ppalka at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94772

Patrick Palka  changed:

   What|Removed |Added

 Resolution|--- |FIXED
 Status|ASSIGNED|RESOLVED

--- Comment #4 from Patrick Palka  ---
Fixed.

[Bug c++/94772] [10 Regression] constructing constexpr variables fail with delegated constexpr constructors

2020-04-27 Thread cvs-commit at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94772

--- Comment #3 from CVS Commits  ---
The master branch has been updated by Patrick Palka :

https://gcc.gnu.org/g:64da1b761db248f4f0d2235a6055c025fbbc94eb

commit r10-7996-g64da1b761db248f4f0d2235a6055c025fbbc94eb
Author: Patrick Palka 
Date:   Mon Apr 27 17:06:35 2020 -0400

c++: Delegating constructor in constexpr init [PR94772]

In the first testcase below, the call to the target constructor foo{} from
foo's
delegating constructor is encoded as the INIT_EXPR

  *(struct foo *) this = AGGR_INIT_EXPR <4, __ct_comp, D.2140, ...>;

During initialization of the variable 'bar', we prematurely set
TREE_READONLY on
bar's CONSTRUCTOR in two places before the outer delegating constructor has
returned: first, at the end of cxx_eval_call_expression after evaluating
the RHS
of the above INIT_EXPR, and second, at the end of cxx_eval_store_expression
after having finished evaluating the above INIT_EXPR.  This then prevents
the
rest of the outer delegating constructor from mutating 'bar'.

This (hopefully minimally risky) patch makes cxx_eval_call_expression
refrain
from setting TREE_READONLY when evaluating the target constructor of a
delegating constructor.  It also makes cxx_eval_store_expression refrain
from
setting TREE_READONLY when the object being initialized is "*this', on the
basis
that it should be the responsibility of the routine that set 'this' in the
first
place to set the object's TREE_READONLY appropriately.

gcc/cp/ChangeLog:

PR c++/94772
* constexpr.c (cxx_eval_call_expression): Don't set new_obj if
we're
evaluating the target constructor of a delegating constructor.
(cxx_eval_store_expression): Don't set TREE_READONLY if the LHS of
the
INIT_EXPR is '*this'.

gcc/testsuite/ChangeLog:

PR c++/94772
* g++.dg/cpp1y/constexpr-tracking-const23.C: New test.
* g++.dg/cpp1y/constexpr-tracking-const24.C: New test.
* g++.dg/cpp1y/constexpr-tracking-const25.C: New test.

[Bug c++/94772] [10 Regression] constructing constexpr variables fail with delegated constexpr constructors

2020-04-27 Thread rguenth at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94772

Richard Biener  changed:

   What|Removed |Added

   Keywords||rejects-valid
   Priority|P3  |P1

[Bug c++/94772] [10 Regression] constructing constexpr variables fail with delegated constexpr constructors

2020-04-26 Thread ppalka at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94772

Patrick Palka  changed:

   What|Removed |Added

 Status|NEW |ASSIGNED
 CC||ppalka at gcc dot gnu.org
   Assignee|unassigned at gcc dot gnu.org  |ppalka at gcc dot 
gnu.org

--- Comment #2 from Patrick Palka  ---
Created attachment 48378
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=48378=edit
patch in testing

I am testing the attached patch.

[Bug c++/94772] [10 Regression] constructing constexpr variables fail with delegated constexpr constructors

2020-04-26 Thread jakub at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94772

Jakub Jelinek  changed:

   What|Removed |Added

   Last reconfirmed||2020-04-26
 Status|UNCONFIRMED |NEW
   Target Milestone|--- |10.0
 Ever confirmed|0   |1
 CC||jakub at gcc dot gnu.org,
   ||jason at gcc dot gnu.org

--- Comment #1 from Jakub Jelinek  ---
Started with r10-7490-g76f09260b7eccd6c3cfa3dcf3c22897fe12a8065