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++/105491] [10/11/12 Regression] Usage of __constinit with -std=c++11 does is rejected
Date: Wed, 01 Jun 2022 12:51:26 +0000	[thread overview]
Message-ID: <bug-105491-4-lI4us53DaW@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-105491-4@http.gcc.gnu.org/bugzilla/>

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

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

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

commit r12-8445-ge30b73bad9486f11b6b0022ae4a3edfc0f9da4bb
Author: Patrick Palka <ppalka@redhat.com>
Date:   Wed Jun 1 08:47:25 2022 -0400

    c++: constexpr init of union sub-aggr w/ base [PR105491]

    Here ever since r10-7313-gb599bf9d6d1e18, reduced_constant_expression_p
    in C++11/14 is rejecting the marked sub-aggregate initializer (of type S)

      W w = {.D.2445={.s={.D.2387={.m=0}, .b=0}}};
                         ^
    ultimately because said initializer has CONSTRUCTOR_NO_CLEARING set,
    hence the function must verify that all fields of S are initialized.
    And before C++17 it doesn't expect to see base class fields (since
    next_initializable_field skips over them), so the presence thereof
    causes r_c_e_p to return false.

    The reason r10-7313-gb599bf9d6d1e18 causes this is because in that
    commit we began using CONSTRUCTOR_NO_CLEARING to precisely track whether
    we're in middle of activating a union member.  This ends up affecting
    clear_no_implicit_zero, which recurses into sub-aggregate initializers
    only if the outer initializer has CONSTRUCTOR_NO_CLEARING set.  After
    that commit, the outer union initializer above no longer has the flag
    set at this point and so clear_no_implicit_zero no longer recurses into
    the marked inner initializer.

    But arguably r_c_e_p should be able to accept the marked initializer
    regardless of whether CONSTRUCTOR_NO_CLEARING is set.  The primary bug
    therefore seems to be that r_c_e_p relies on next_initializable_field
    which skips over base class fields in C++11/14.  To fix this, this patch
    introduces a new helper function next_subobject_field which is like
    next_initializable_field except that it never skips base class fields,
    and makes r_c_e_p use it.  This patch then renames next_initializable_field
    to next_aggregate_field (and makes it skip over vptr fields again).

    NB: This minimal backport of r13-211-g0c7bce0ac184c0 for 12.2 just adds
    next_subobject_field and makes reduced_constant_expression_p use it.

            PR c++/105491

    gcc/cp/ChangeLog:

            * constexpr.cc (reduced_constant_expression_p): Use
            next_subobject_field instead.
            * cp-tree.h (next_subobject_field): Declare.
            * decl.cc (next_subobject_field): Define.

    gcc/testsuite/ChangeLog:

            * g++.dg/cpp0x/constexpr-union7.C: New test.
            * g++.dg/cpp0x/constexpr-union7a.C: New test.
            * g++.dg/cpp2a/constinit17.C: New test.

    (cherry picked from commit 0c7bce0ac184c057bacad9c8e615ce82923835fd)

  parent reply	other threads:[~2022-06-01 12:51 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <bug-105491-4@http.gcc.gnu.org/bugzilla/>
2022-05-05 11:55 ` [Bug c++/105491] " redi at gcc dot gnu.org
2022-05-05 14:38 ` mpolacek at gcc dot gnu.org
2022-05-05 14:48 ` [Bug c++/105491] [10/11/12/13 Regression] " jakub at gcc dot gnu.org
2022-05-05 14:51 ` mpolacek at gcc dot gnu.org
2022-05-05 14:57 ` mpolacek at gcc dot gnu.org
2022-05-05 14:58 ` mpolacek at gcc dot gnu.org
2022-05-05 15:01 ` mpolacek at gcc dot gnu.org
2022-05-06 13:47 ` ppalka at gcc dot gnu.org
2022-05-09 13:53 ` cvs-commit at gcc dot gnu.org
2022-05-16  8:46 ` [Bug c++/105491] [10/11/12 " marxin at gcc dot gnu.org
2022-06-01 12:51 ` cvs-commit at gcc dot gnu.org [this message]
2022-06-01 12:53 ` [Bug c++/105491] [10/11 " ppalka at gcc dot gnu.org
2022-06-28 10:49 ` jakub at gcc dot gnu.org
2023-05-21 15:05 ` 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-105491-4-lI4us53DaW@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).