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

            Bug ID: 125043
           Summary: regression: ICE in passing invalid constant template
                    argument
           Product: gcc
           Version: 16.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: barry.revzin at gmail dot com
  Target Milestone: ---

Consider this example:

template <auto V>
struct wrapper {
    static constexpr const auto& value = V;
};

template <int const& I>
auto f() -> void;

auto main() -> int {
    f<wrapper<42>::value>();
}

This should be ill-formed, and gcc 14.3 and 15.2 reject it as expected. But gcc
trunk ICEs (regardless of -std=c++20, c++23, or c++26):

<source>:10:26: internal compiler error: in invalid_tparm_referent_p, at
cp/pt.cc:7453
   10 |     f<wrapper<42>::value>();
      |     ~~~~~~~~~~~~~~~~~~~~~^~
0x2975fc8 diagnostics::context::diagnostic_impl(rich_location*,
diagnostics::metadata const*, diagnostics::option_id, char const*,
__va_list_tag (*) [1], diagnostics::kind)
        ???:0
0x296ac0b internal_error(char const*, ...)
        ???:0
0xb267a4 fancy_abort(char const*, int, char const*)
        ???:0
0xdc1203 coerce_template_parms(tree_node*, tree_node*, tree_node*, int, bool)
        ???:0
0xddca23 fn_type_unification(tree_node*, tree_node*, tree_node*, tree_node*
const*, unsigned int, tree_node*, unification_kind_t, int, conversion**, bool,
bool)
        ???:0
0xb5f1ff build_new_function_call(tree_node*, vec<tree_node*, va_gc,
vl_embed>**, int)
        ???:0
0xe16815 finish_call_expr(tree_node*, vec<tree_node*, va_gc, vl_embed>**, bool,
bool, int)
        ???:0
0xd75e63 c_parse_file()
        ???:0
0xf03889 c_common_parse_file()
        ???:0

Reply via email to