https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117792
Bug ID: 117792
Summary: ICE in tsubst_template_args
Product: gcc
Version: 15.0
URL: https://bugs.linaro.org/show_bug.cgi?id=6058
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: clyon at gcc dot gnu.org
Target Milestone: ---
As described in https://bugs.linaro.org/show_bug.cgi?id=6058, this short code
fragment:
==================================
template <const char *fmt, unsigned int fmt_len, typename... Args>
static void printf_impl(const char *, Args... args)
{}
struct Wrapper
{
template <typename... Args>
static void make(Args &&... args)
{
static const char fmt[] = "";
printf_impl<fmt, 2>("");
}
};
int main()
{
Wrapper::make();
return 0;
}
==================================
causes GCC to crash on trunk, since gcc-12.1 according to godbolt, and compiles
OK with gcc-11.4.
It crashes for x86_64, aarch64, arm target at least.
The backtrace from godbolt:
<source>: In instantiation of 'static void Wrapper::make(Args&& ...) [with Args
= {}]':
<source>:17:18: required from here
17 | Wrapper::make();
| ~~~~~~~~~~~~~^~
<source>:2:13: internal compiler error: tree check: accessed elt 2 of
'tree_vec' with 1 elts in tsubst, at cp/pt.cc:16467
2 | static void printf_impl(const char *, Args... args)
| ^~~~~~~~~~~
0x28cf075 diagnostic_context::diagnostic_impl(rich_location*,
diagnostic_metadata const*, diagnostic_option_id, char const*, __va_list_tag
(*) [1], diagnostic_t)
???:0
0x28e5d65 internal_error(char const*, ...)
???:0
0x9a4c09 tree_vec_elt_check_failed(int, int, char const*, int, char const*)
???:0
0xcef624 tsubst_template_args(tree_node*, tree_node*, int, tree_node*)
???:0
0xcd07ad instantiate_decl(tree_node*, bool, bool)
???:0
0xd0ba1b instantiate_pending_templates(int)
???:0
0xb9d23b c_parse_final_cleanups()
???:0
0xe048c8 c_common_parse_file()
???:0