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++/107574] [10/11/12/13 Regression] ICE: tree check in cp_fold_convert with ptr to member field cast inside a class not completed and inherent since r9-50-gd760b06868d660bc
Date: Wed, 01 Mar 2023 23:33:17 +0000	[thread overview]
Message-ID: <bug-107574-4-TJBZk83qc9@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-107574-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #7 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The trunk branch has been updated by Marek Polacek <mpolacek@gcc.gnu.org>:

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

commit r13-6400-gde81e06273c613d7e06cbe2c8d9e72826c638056
Author: Marek Polacek <polacek@redhat.com>
Date:   Thu Feb 2 18:15:37 2023 -0500

    c++: can't eval PTRMEM_CST in incomplete class [PR107574]

    Here we're attempting to evaluate a PTRMEM_CST in a class that hasn't
    been completed yet, but that doesn't work:

            /* We can't lower this until the class is complete.  */
            if (!COMPLETE_TYPE_P (DECL_CONTEXT (member)))
              return cst;

    and then this unlowered PTRMEM_CST is used as EXPR in

        tree op1 = build_nop (ptrdiff_type_node, expr);

    and we crash in a subsequent cp_fold_convert which gets
type=ptrdiff_type_node,
    expr=PTRMEM_CST and does

      else if (TREE_CODE (expr) == PTRMEM_CST
               && same_type_p (TYPE_PTRMEM_CLASS_TYPE (type),
                               PTRMEM_CST_CLASS (expr)))

    where TYPE_PTRMEM_CLASS_TYPE (type) is going to crash since the type
    is ptrdiff_type_node.  We could just add a TYPE_PTRMEM_P check before
    accessing TYPE_PTRMEM_CLASS_TYPE but I think it's nicer to explain why
    we couldn't evaluate the expression.

            PR c++/107574

    gcc/cp/ChangeLog:

            * constexpr.cc (cxx_eval_constant_expression): Emit an error when
            a PTRMEM_CST cannot be evaluated.

    gcc/testsuite/ChangeLog:

            * g++.dg/cpp0x/ptrmem-cst1.C: New test.

  parent reply	other threads:[~2023-03-01 23:33 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-08 17:25 [Bug c++/107574] New: [10/11/12/13 Regression] ICE: tree check: expected record_type or union_type or qual_union_type, have integer_type in cp_fold_convert, at cp/cvt.cc:613 gscfq@t-online.de
2022-11-08 17:37 ` [Bug c++/107574] " rguenth at gcc dot gnu.org
2022-11-08 17:43 ` [Bug c++/107574] [10/11/12/13 Regression] ICE: tree check in cp_fold_convert with ptr to member field cast inside a class not completed and inherent pinskia at gcc dot gnu.org
2022-11-08 17:45 ` pinskia at gcc dot gnu.org
2022-11-08 17:51 ` pinskia at gcc dot gnu.org
2022-11-21 12:04 ` [Bug c++/107574] [10/11/12/13 Regression] ICE: tree check in cp_fold_convert with ptr to member field cast inside a class not completed and inherent since r9-50-gd760b06868d660bc marxin at gcc dot gnu.org
2023-01-31 23:42 ` mpolacek at gcc dot gnu.org
2023-02-02 17:28 ` mpolacek at gcc dot gnu.org
2023-03-01 23:33 ` cvs-commit at gcc dot gnu.org [this message]
2023-03-01 23:34 ` [Bug c++/107574] [10/11/12 " mpolacek at gcc dot gnu.org
2023-03-04 17:51 ` cvs-commit at gcc dot gnu.org
2023-03-04 17:52 ` [Bug c++/107574] [10/11 " mpolacek 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-107574-4-TJBZk83qc9@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).