public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/94470] New: Constexpr variable initialization with self-modifying constructor incorrectly rejected since r7-6728
@ 2020-04-03 13:43 ppalka at gcc dot gnu.org
  2020-04-03 13:53 ` [Bug c++/94470] [8/9/10 Regression] " ppalka at gcc dot gnu.org
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: ppalka at gcc dot gnu.org @ 2020-04-03 13:43 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 94470
           Summary: Constexpr variable initialization with self-modifying
                    constructor incorrectly rejected since r7-6728
           Product: gcc
           Version: 10.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ppalka at gcc dot gnu.org
  Target Milestone: ---

$ cat testcase.C
struct X
{
  int b = 0;
  int c = ((this->b=1), 1);
};

constexpr X o = { };

static_assert(o.b == 1);

$ g++ -std=c++17 testcase.C
testcase.C:7:19: error: modification of ‘o’ is not a constant expression
 constexpr X o = { };
                   ^
testcase.C:9:19: error: non-constant condition for static assertion
 static_assert(o.b == 1);
               ~~~~^~~~

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug c++/94470] [8/9/10 Regression] Constexpr variable initialization with self-modifying constructor incorrectly rejected since r7-6728
  2020-04-03 13:43 [Bug c++/94470] New: Constexpr variable initialization with self-modifying constructor incorrectly rejected since r7-6728 ppalka at gcc dot gnu.org
@ 2020-04-03 13:53 ` ppalka at gcc dot gnu.org
  2020-04-03 13:57 ` mpolacek at gcc dot gnu.org
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: ppalka at gcc dot gnu.org @ 2020-04-03 13:53 UTC (permalink / raw)
  To: gcc-bugs

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

Patrick Palka <ppalka at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
      Known to fail|                            |10.0, 7.5.0, 8.4.0, 9.3.0
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2020-04-03
      Known to work|                            |6.5.0
                 CC|                            |jason at gcc dot gnu.org
           Keywords|                            |ice-on-valid-code
   Target Milestone|---                         |10.0
            Summary|Constexpr variable          |[8/9/10 Regression]
                   |initialization with         |Constexpr variable
                   |self-modifying constructor  |initialization with
                   |incorrectly rejected since  |self-modifying constructor
                   |r7-6728                     |incorrectly rejected since
                   |                            |r7-6728

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug c++/94470] [8/9/10 Regression] Constexpr variable initialization with self-modifying constructor incorrectly rejected since r7-6728
  2020-04-03 13:43 [Bug c++/94470] New: Constexpr variable initialization with self-modifying constructor incorrectly rejected since r7-6728 ppalka at gcc dot gnu.org
  2020-04-03 13:53 ` [Bug c++/94470] [8/9/10 Regression] " ppalka at gcc dot gnu.org
@ 2020-04-03 13:57 ` mpolacek at gcc dot gnu.org
  2020-04-03 13:57 ` mpolacek at gcc dot gnu.org
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2020-04-03 13:57 UTC (permalink / raw)
  To: gcc-bugs

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

Marek Polacek <mpolacek at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |mpolacek at gcc dot gnu.org
           Priority|P3                          |P2
           Keywords|ice-on-valid-code           |rejects-valid

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug c++/94470] [8/9/10 Regression] Constexpr variable initialization with self-modifying constructor incorrectly rejected since r7-6728
  2020-04-03 13:43 [Bug c++/94470] New: Constexpr variable initialization with self-modifying constructor incorrectly rejected since r7-6728 ppalka at gcc dot gnu.org
  2020-04-03 13:53 ` [Bug c++/94470] [8/9/10 Regression] " ppalka at gcc dot gnu.org
  2020-04-03 13:57 ` mpolacek at gcc dot gnu.org
@ 2020-04-03 13:57 ` mpolacek at gcc dot gnu.org
  2020-04-13 12:11 ` ppalka at gcc dot gnu.org
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2020-04-03 13:57 UTC (permalink / raw)
  To: gcc-bugs

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

Marek Polacek <mpolacek at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|10.0                        |8.5

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug c++/94470] [8/9/10 Regression] Constexpr variable initialization with self-modifying constructor incorrectly rejected since r7-6728
  2020-04-03 13:43 [Bug c++/94470] New: Constexpr variable initialization with self-modifying constructor incorrectly rejected since r7-6728 ppalka at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2020-04-03 13:57 ` mpolacek at gcc dot gnu.org
@ 2020-04-13 12:11 ` ppalka at gcc dot gnu.org
  2020-04-13 21:04 ` cvs-commit at gcc dot gnu.org
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: ppalka at gcc dot gnu.org @ 2020-04-13 12:11 UTC (permalink / raw)
  To: gcc-bugs

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

Patrick Palka <ppalka at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
           Assignee|unassigned at gcc dot gnu.org      |ppalka at gcc dot gnu.org

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug c++/94470] [8/9/10 Regression] Constexpr variable initialization with self-modifying constructor incorrectly rejected since r7-6728
  2020-04-03 13:43 [Bug c++/94470] New: Constexpr variable initialization with self-modifying constructor incorrectly rejected since r7-6728 ppalka at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2020-04-13 12:11 ` ppalka at gcc dot gnu.org
@ 2020-04-13 21:04 ` cvs-commit at gcc dot gnu.org
  2020-04-13 21:06 ` [Bug c++/94470] [8/9 " ppalka at gcc dot gnu.org
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-04-13 21:04 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 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:077dd9b3f17710da8af6adce816754ddceb57b5a

commit r10-7704-g077dd9b3f17710da8af6adce816754ddceb57b5a
Author: Patrick Palka <ppalka@redhat.com>
Date:   Mon Apr 13 16:53:02 2020 -0400

    c++: More self-modifying constexpr init [PR94470]

    In this PR we're incorrectly rejecting a self-modifying constexpr
initializer as
    a consequence of the fix for PR78572.

    It looks like however that the fix for PR78572 is obsoleted by the fix for
    PR89336: the testcase from the former PR successfully compiles even with
its fix
    reverted.

    But then further testing showed that the analogous testcase of PR78572
where the
    array has an aggregate element type is still problematic (i.e. we ICE) even
with
    the fix for PR78572 applied.  The reason is that in cxx_eval_bare_aggregate
we
    attach a constructor_elt of aggregate type always to the end of the new
    CONSTRUCTOR, but that's not necessarily correct if the CONSTRUCTOR is
    self-modifying.  We should instead be using get_or_insert_ctor_field to
insert
    the constructor_elt in the right place.

    So this patch reverts the PR78572 fix and makes the appropriate changes to
    cxx_eval_bare_aggregate.  This fixes PR94470, and we now are also able to
fully
    reduce the initializers of 'arr' and 'arr2' in the new test array57.C to
    constant initializers.

    gcc/cp/ChangeLog:

            PR c++/94470
            * constexpr.c (get_or_insert_ctor_field): Set default value of
parameter
            'pos_hint' to -1.
            (cxx_eval_bare_aggregate): Use get_or_insert_ctor_field instead of
            assuming the the next index belongs at the end of the new
CONSTRUCTOR.
            (cxx_eval_store_expression): Revert PR c++/78572 fix.

    gcc/testsuite/ChangeLog:

            PR c++/94470
            * g++.dg/cpp1y/constexpr-nsdmi8.C: New test.
            * g++.dg/cpp1y/constexpr-nsdmi9.C: New test.
            * g++.dg/init/array57.C: New test.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug c++/94470] [8/9 Regression] Constexpr variable initialization with self-modifying constructor incorrectly rejected since r7-6728
  2020-04-03 13:43 [Bug c++/94470] New: Constexpr variable initialization with self-modifying constructor incorrectly rejected since r7-6728 ppalka at gcc dot gnu.org
                   ` (4 preceding siblings ...)
  2020-04-13 21:04 ` cvs-commit at gcc dot gnu.org
@ 2020-04-13 21:06 ` ppalka at gcc dot gnu.org
  2021-05-14  9:53 ` [Bug c++/94470] [9 " jakub at gcc dot gnu.org
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: ppalka at gcc dot gnu.org @ 2020-04-13 21:06 UTC (permalink / raw)
  To: gcc-bugs

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

Patrick Palka <ppalka at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|[8/9/10 Regression]         |[8/9 Regression] Constexpr
                   |Constexpr variable          |variable initialization
                   |initialization with         |with self-modifying
                   |self-modifying constructor  |constructor incorrectly
                   |incorrectly rejected since  |rejected since r7-6728
                   |r7-6728                     |

--- Comment #2 from Patrick Palka <ppalka at gcc dot gnu.org> ---
Fixed for GCC 10 so far.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug c++/94470] [9 Regression] Constexpr variable initialization with self-modifying constructor incorrectly rejected since r7-6728
  2020-04-03 13:43 [Bug c++/94470] New: Constexpr variable initialization with self-modifying constructor incorrectly rejected since r7-6728 ppalka at gcc dot gnu.org
                   ` (5 preceding siblings ...)
  2020-04-13 21:06 ` [Bug c++/94470] [8/9 " ppalka at gcc dot gnu.org
@ 2021-05-14  9:53 ` jakub at gcc dot gnu.org
  2021-06-01  8:17 ` rguenth at gcc dot gnu.org
  2022-05-27  8:51 ` rguenth at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: jakub at gcc dot gnu.org @ 2021-05-14  9:53 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|8.5                         |9.4

--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
GCC 8 branch is being closed.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug c++/94470] [9 Regression] Constexpr variable initialization with self-modifying constructor incorrectly rejected since r7-6728
  2020-04-03 13:43 [Bug c++/94470] New: Constexpr variable initialization with self-modifying constructor incorrectly rejected since r7-6728 ppalka at gcc dot gnu.org
                   ` (6 preceding siblings ...)
  2021-05-14  9:53 ` [Bug c++/94470] [9 " jakub at gcc dot gnu.org
@ 2021-06-01  8:17 ` rguenth at gcc dot gnu.org
  2022-05-27  8:51 ` rguenth at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-06-01  8:17 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|9.4                         |9.5

--- Comment #4 from Richard Biener <rguenth at gcc dot gnu.org> ---
GCC 9.4 is being released, retargeting bugs to GCC 9.5.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug c++/94470] [9 Regression] Constexpr variable initialization with self-modifying constructor incorrectly rejected since r7-6728
  2020-04-03 13:43 [Bug c++/94470] New: Constexpr variable initialization with self-modifying constructor incorrectly rejected since r7-6728 ppalka at gcc dot gnu.org
                   ` (7 preceding siblings ...)
  2021-06-01  8:17 ` rguenth at gcc dot gnu.org
@ 2022-05-27  8:51 ` rguenth at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-05-27  8:51 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|9.5                         |10.0
         Resolution|---                         |FIXED
             Status|ASSIGNED                    |RESOLVED

--- Comment #5 from Richard Biener <rguenth at gcc dot gnu.org> ---
Fixed in GCC 10.

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2022-05-27  8:51 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-03 13:43 [Bug c++/94470] New: Constexpr variable initialization with self-modifying constructor incorrectly rejected since r7-6728 ppalka at gcc dot gnu.org
2020-04-03 13:53 ` [Bug c++/94470] [8/9/10 Regression] " ppalka at gcc dot gnu.org
2020-04-03 13:57 ` mpolacek at gcc dot gnu.org
2020-04-03 13:57 ` mpolacek at gcc dot gnu.org
2020-04-13 12:11 ` ppalka at gcc dot gnu.org
2020-04-13 21:04 ` cvs-commit at gcc dot gnu.org
2020-04-13 21:06 ` [Bug c++/94470] [8/9 " ppalka at gcc dot gnu.org
2021-05-14  9:53 ` [Bug c++/94470] [9 " jakub at gcc dot gnu.org
2021-06-01  8:17 ` rguenth at gcc dot gnu.org
2022-05-27  8:51 ` rguenth at gcc dot gnu.org

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).