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++/102786] [c++20] virtual pmf sometimes rejected as not a constant
Date: Tue, 19 Oct 2021 07:25:44 +0000	[thread overview]
Message-ID: <bug-102786-4-PVA3YKZtVc@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-102786-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #3 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jakub Jelinek <jakub@gcc.gnu.org>:

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

commit r12-4491-gf45610a45236e97616726ca042898d6ac46a082e
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Tue Oct 19 09:24:57 2021 +0200

    c++: Don't reject calls through PMF during constant evaluation [PR102786]

    The following testcase incorrectly rejects the c initializer,
    while in the s.*a case cxx_eval_* sees .__pfn reads etc.,
    in the s.*&S::foo case get_member_function_from_ptrfunc creates
    expressions which use INTEGER_CSTs with type of pointer to METHOD_TYPE.
    And cxx_eval_constant_expression rejects any INTEGER_CSTs with pointer
    type if they aren't 0.
    Either we'd need to make sure we defer such folding till cp_fold but the
    function and pfn_from_ptrmemfunc is used from lots of places, or
    the following patch just tries to reject only non-zero INTEGER_CSTs
    with pointer types if they don't point to METHOD_TYPE in the hope that
    all such INTEGER_CSTs with POINTER_TYPE to METHOD_TYPE are result of
    folding valid pointer-to-member function expressions.
    I don't immediately see how one could create such INTEGER_CSTs otherwise,
    cast of integers to PMF is rejected and would have the PMF RECORD_TYPE
    anyway, etc.

    2021-10-19  Jakub Jelinek  <jakub@redhat.com>

            PR c++/102786
            * constexpr.c (cxx_eval_constant_expression): Don't reject
            INTEGER_CSTs with type POINTER_TYPE to METHOD_TYPE.

            * g++.dg/cpp2a/constexpr-virtual19.C: New test.

  parent reply	other threads:[~2021-10-19  7:25 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-15 18:05 [Bug c++/102786] New: PMF constant evaluation bug jakub at gcc dot gnu.org
2021-10-15 19:22 ` [Bug c++/102786] " pinskia at gcc dot gnu.org
2021-10-15 20:32 ` pinskia at gcc dot gnu.org
2021-10-19  7:25 ` cvs-commit at gcc dot gnu.org [this message]
2021-11-29  8:49 ` [Bug c++/102786] [c++20] virtual pmf sometimes rejected as not a constant cvs-commit at gcc dot gnu.org
2021-11-29  9:08 ` jakub at gcc dot gnu.org
2022-05-10  8:21 ` cvs-commit at gcc dot gnu.org
2022-05-11  6:22 ` cvs-commit at gcc dot gnu.org
2022-10-28 23:28 ` pinskia 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-102786-4-PVA3YKZtVc@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).