https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91575
Bug ID: 91575
Summary: ice: tree check: expected integer_cst, have minus_expr
in get_len, at tree.h:5826
Product: gcc
Version: 10.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: dcb314 at hotmail dot com
Target Milestone: ---
For this C source code:
b[];
c;
*stpcpy(char *, char *);
a() __attribute__((format(printf, 2, 2 + 1)));
d() {
__builtin___strcpy_chk(b, 0, 0);
a(d, " failed to create token cursor %.*s %.*s%s%s", "", c ? b : "");
}
compiled by recent gcc trunk and compiler flag -O2, does this:
during GIMPLE pass: strlen
bug540.c: In function ādā:
bug540.c:5:6: internal compiler error: tree check: expected integer_cst, have
mi
nus_expr in get_len, at tree.h:5826
5 | void d() {
| ^
0x7345cb tree_check_failed(tree_node const*, char const*, int, char const*,
...)
../../trunk/gcc/tree.c:9925
0x712b5e tree_check(tree_node const*, char const*, int, char const*, tree_code)
../../trunk/gcc/tree.h:3519
0x712b5e wi::extended_tree<192>::get_len() const
../../trunk/gcc/tree.h:5826
0x712b5e wi::int_traits<generic_wide_int<wi::extended_tree<192> >
>::decompose(l
ong*, unsigned int, generic_wide_int<wi::extended_tree<192> > const&)
../../trunk/gcc/wide-int.h:983
The bug seems to first occur between revision 274850 and 274950.