https://gcc.gnu.org/bugzilla/show_bug.cgi?id=126326
Bug ID: 126326
Summary: ICE with gnu::format attribute on variadic template
function
Product: gcc
Version: 17.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: s.kimura.h41104 at gmail dot com
Target Milestone: ---
Compiler Explorer: https://godbolt.org/z/vs7jn61fn
Reproducer:
```
template <typename... T>
int foo(T... args, const char *fmt, ...)
[[gnu::format(printf, sizeof...(T), int)]];
int bar = foo<>("%f", 1);
```
Backtrace:
<source>:3:41: error: expected primary-expression before 'int'
3 | [[gnu::format(printf, sizeof...(T), int)]];
| ^~~
<source>: In substitution of 'template<class ... T> int foo(T ..., const char*,
...) [with T = <missing>]':
<source>:5:16: required from here
5 | int bar = foo<>("%f", 1);
| ~~~~~^~~~~~~~~
<source>:2:5: internal compiler error: tree check: expected tree_list, have
error_mark in is_late_template_attribute, at cp/decl2.cc:1729
2 | int foo(T... args, const char *fmt, ...)
| ^~~
0x2b4dc08 diagnostics::context::diagnostic_impl(rich_location*,
diagnostics::metadata const*, diagnostics::option_id, char const*,
__va_list_tag (*) [1], diagnostics::kind)
???:0
0x2b4284b internal_error(char const*, ...)
???:0
0xa385ec tree_check_failed(tree_node const*, char const*, int, char const*,
...)
???:0
0xc57646 cplus_decl_attributes(tree_node**, tree_node*, int)
???:0
0xdc9e66 tsubst(tree_node*, tree_node*, int, tree_node*)
???:0
0xdf8305 fn_type_unification(tree_node*, tree_node*, tree_node*, tree_node*
const*, unsigned int, tree_node*, unification_kind_t, int, conversion**, bool,
bool)
???:0
0xb7410f build_new_function_call(tree_node*, vec<tree_node*, va_gc,
vl_embed>**, int)
???:0
0xe334bd finish_call_expr(tree_node*, vec<tree_node*, va_gc, vl_embed>**, bool,
bool, int)
???:0
0xd90413 c_parse_file()
???:0
0xf22c69 c_common_parse_file()
???:0
This ICE goes back to gcc-15:
https://godbolt.org/z/fjx3Wjj11