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++/108550] [10/11/12 Regression] the type 'const auto' of 'constexpr' variable is not literal
Date: Sat, 04 Mar 2023 18:14:56 +0000	[thread overview]
Message-ID: <bug-108550-4-2tczMvcfSa@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-108550-4@http.gcc.gnu.org/bugzilla/>

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

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

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

commit r12-9219-gd6419c18056ae27741e961cd2dab9d120bfe746a
Author: Marek Polacek <polacek@redhat.com>
Date:   Sat Mar 4 13:14:01 2023 -0500

    c++: variable template and targ deduction [PR108550]

    In this test, we get a bogus error because we failed to deduce the auto in
    constexpr auto is_pointer_v = is_pointer<Tp>::value;
    to bool.  Then ensure_literal_type_for_constexpr_object thinks the object
    isn't literal and an error is reported.

    This is another case of the interaction between tf_partial and 'auto',
    where the auto was not reduced so the deduction failed.  In more detail:
    we have

      Wrap1<int>()

    in the code and we need to perform OR -> fn_type_unification.  The targ
    list is incomplete, so we do
          tsubst_flags_t ecomplain = complain | tf_partial | tf_fndecl_type;
          fntype = tsubst (TREE_TYPE (fn), explicit_targs, ecomplain,
NULL_TREE);
    where TREE_TYPE (fn) is struct integral_constant <T402> (void).  Then
    we substitute the return type, which results in tsubsting
is_pointer_v<int>.
    is_pointer_v is a variable template with a placeholder type:

      template <class Tp>
      constexpr auto is_pointer_v = is_pointer<Tp>::value;

    so we find ourselves in lookup_and_finish_template_variable.  tf_partial is
    still set, so finish_template_variable -> instantiate_template -> tsubst
    won't reduce the level of auto.  But then we do mark_used which eventually
    calls do_auto_deduction which clears tf_partial, because we want to replace
    the auto now.  But we hadn't reduced auto's level so this fails.  And
    since we're not in an immediate context, we emit a hard error.

    I suppose that when we reach lookup_and_finish_template_variable it's
    probably time to clear tf_partial.  (I added an assert and our testsuite
    doesn't have a test whereby we get to lookup_and_finish_template_variable
    while tf_partial is still active.)

            PR c++/108550

    gcc/cp/ChangeLog:

            * pt.cc (lookup_and_finish_template_variable): Clear tf_partial.

    gcc/testsuite/ChangeLog:

            * g++.dg/cpp1y/var-templ70.C: New test.
            * g++.dg/cpp1y/var-templ71.C: New test.
            * g++.dg/cpp1y/var-templ72.C: New test.

  parent reply	other threads:[~2023-03-04 18:14 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-26  6:25 [Bug c++/108550] New: " coyorkdow at outlook dot com
2023-01-27  0:07 ` [Bug c++/108550] " pinskia at gcc dot gnu.org
2023-01-27  0:21 ` pinskia at gcc dot gnu.org
2023-01-27  0:24 ` [Bug c++/108550] [10/11/12/13 Regression] " pinskia at gcc dot gnu.org
2023-02-20 18:19 ` mpolacek at gcc dot gnu.org
2023-02-20 18:25 ` pinskia at gcc dot gnu.org
2023-02-20 18:31 ` mpolacek at gcc dot gnu.org
2023-02-20 21:17 ` mpolacek at gcc dot gnu.org
2023-02-21 12:52 ` rguenth at gcc dot gnu.org
2023-02-21 16:28 ` mpolacek at gcc dot gnu.org
2023-02-28 15:16 ` cvs-commit at gcc dot gnu.org
2023-02-28 15:16 ` [Bug c++/108550] [10/11/12 " mpolacek at gcc dot gnu.org
2023-03-04 18:14 ` cvs-commit at gcc dot gnu.org [this message]
2023-03-04 18:18 ` mpolacek at gcc dot gnu.org
2023-03-04 18:25 ` 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-108550-4-2tczMvcfSa@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).