public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "janpmoeller at gmx dot de" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/112769] New: ICE on valid code related to requires-expression
Date: Wed, 29 Nov 2023 19:25:03 +0000	[thread overview]
Message-ID: <bug-112769-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 112769
           Summary: ICE on valid code related to requires-expression
           Product: gcc
           Version: 13.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: janpmoeller at gmx dot de
  Target Milestone: ---

All gcc versions since (and including) 11.2 reject the following valid C++20
code:

//////////////////////////////////////////////////////////////
template<int I, typename T>
struct type
{
    constexpr explicit type(T value)
    {
    }

    template<typename U>
    constexpr explicit type(type<I, U> value)
        requires requires { T{value}; }
    {
    }
};

template <typename T>
using alias = type<0, T>;

constexpr alias foo{123};
//////////////////////////////////////////////////////////////


The reported error is:

##############################################################
<source>:11:18: internal compiler error: in add_outermost_template_args, at
cp/pt.cc:617
   11 |         requires requires { T{value}; }
      |                  ^~~~~~~~~~~~~~~~~~~~~~
0x1ce7bde internal_error(char const*, ...)
        ???:0
0x7290fc fancy_abort(char const*, int, char const*)
        ???:0
0x7879b6 tsubst_requires_expr(tree_node*, tree_node*, int, tree_node*)
        ???:0
0x783c90 tsubst_constraint(tree_node*, tree_node*, int, tree_node*)
        ???:0
0x783df1 tsubst_constraint_info(tree_node*, tree_node*, int, tree_node*)
        ???:0
0x8b1e90 do_auto_deduction(tree_node*, tree_node*, tree_node*, int,
auto_deduction_context, tree_node*, int, tree_node*)
        ???:0
0x7ccd01 cp_finish_decl(tree_node*, tree_node*, bool, tree_node*, int)
        ???:0
0x89fd5b c_parse_file()
        ???:0
0x98c5d9 c_common_parse_file()
        ???:0
Please submit a full bug report, with preprocessed source.
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.
Preprocessed source stored into /tmp/cclpGAjI.out file, please attach this to
your bugreport.
Compiler returned: 1
##############################################################

gcc-11.1 accepts the code.Here is a link to compiler explorer with the same
example: https://godbolt.org/z/aq1d53anv

Note that the first (non-template) constructor is required to make the code
valid, but it is not required to reproduce the issue. Removing it still leads
to the same ICE on gcc > 11.1, whereas gcc-11.1 (correctly) rejects it due to
failed argument deduction.

             reply	other threads:[~2023-11-29 19:25 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-29 19:25 janpmoeller at gmx dot de [this message]
2023-11-30 18:48 ` [Bug c++/112769] " janpmoeller at gmx dot de
2024-02-02 17:57 ` [Bug c++/112769] [11/12/13/14 Regression] " ppalka at gcc dot gnu.org
2024-02-02 17:59 ` ppalka at gcc dot gnu.org
2024-02-03  0:07 ` cvs-commit at gcc dot gnu.org
2024-02-03  0:11 ` [Bug c++/112769] [11/12/13 " ppalka at gcc dot gnu.org
2024-04-15 15:34 ` [Bug c++/112769] [11/12 " 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-112769-4@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).