https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109756
Bug ID: 109756
Summary: "internal compiler error: tree check" when using the
[[assume]] attribute with pack expansion
Product: gcc
Version: 14.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: ensadc at mailnesia dot com
Target Milestone: ---
https://godbolt.org/z/WPn9aq8sr
====
bool f(auto... args) {
[[assume(args > 0)...]];
return ((args == 0) && ...);
}
bool g(int a, int b) {
return f(a, b);
}
====
<source>: In function 'bool f(auto:1 ...)':
<source>:2:28: internal compiler error: tree check: expected tree that contains
'common' structure, have 'expr_pack_expansion' in list_length, at tree.cc:3414
2 | [[assume(args > 0)...]];
| ^
0x235945e internal_error(char const*, ...)
???:0
0x96da3a tree_contains_struct_check_failed(tree_node const*,
tree_node_structure_enum, char const*, int, char const*)
???:0
0xb20632 process_stmt_assume_attribute(tree_node*, tree_node*, unsigned int)
???:0
0xc7212f c_parse_file()
???:0
0xdb0d99 c_common_parse_file()
???:0
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.
Compiler returned: 1
====
I believe that [[assume(args > 0)...]] is a valid pack expansion. The standard
says ([temp.variadic]/5):
> Pack expansions can occur in the following contexts:
> (5.8) - In an attribute-list ([dcl.attr.grammar]); the pattern is an
> attribute.