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 via email to