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++/94490] Ternary expression with 3 consts is “not” a constant expression
Date: Thu, 02 Dec 2021 13:21:54 +0000	[thread overview]
Message-ID: <bug-94490-4-feDoE7qjjd@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-94490-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #6 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:9af081003f9c19f33457e0ed1aa14a764f462c3c

commit r12-5712-g9af081003f9c19f33457e0ed1aa14a764f462c3c
Author: Marek Polacek <polacek@redhat.com>
Date:   Sat Nov 6 18:10:39 2021 -0400

    c++: Fix bogus error with __integer_pack [PR94490]

    Here we issue a bogus:

    error: '(0 ? fake_tuple_size_v<int> : fake_tuple_size_v<int>)' is not a
constant expression

    because cxx_constant_value in expand_integer_pack gets

    *(0 ? VIEW_CONVERT_EXPR<const int>(fake_tuple_size_v) :
VIEW_CONVERT_EXPR<const int>(fake_tuple_size_v))

    which is a REFERENCE_REF_P and we evaluate its operand to 3, so we end
    up with *3 and that fails.  Sounds like we need to get rid of the
    REFERENCE_REF_P then.  That is what tsubst_copy_and_build/INDIRECT_REF
    will do:

            if (REFERENCE_REF_P (t))
              {
                /* A type conversion to reference type will be enclosed in
                   such an indirect ref, but the substitution of the cast
                   will have also added such an indirect ref.  */
                r = convert_from_reference (r);
              }

    so I think it's reasonable to call instantiate_non_dependent_expr_sfinae.

            PR c++/94490

    gcc/cp/ChangeLog:

            * pt.c (expand_integer_pack): Call
            instantiate_non_dependent_expr_sfinae.

    gcc/testsuite/ChangeLog:

            * g++.dg/ext/integer-pack5.C: New test.

  parent reply	other threads:[~2021-12-02 13:21 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-05  2:18 [Bug c++/94490] New: " bisqwit at iki dot fi
2020-04-07 22:39 ` [Bug c++/94490] " mpolacek at gcc dot gnu.org
2020-04-08 13:43 ` ensadc at mailnesia dot com
2021-05-27 19:15 ` ppalka at gcc dot gnu.org
2021-05-27 21:03 ` mpolacek at gcc dot gnu.org
2021-12-01 17:23 ` mpolacek at gcc dot gnu.org
2021-12-02 13:21 ` cvs-commit at gcc dot gnu.org [this message]
2021-12-02 13:26 ` cvs-commit at gcc dot gnu.org
2021-12-02 13:28 ` 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-94490-4-feDoE7qjjd@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).