https://gcc.gnu.org/bugzilla/show_bug.cgi?id=125604
Bug ID: 125604
Summary: [17 Regression] ICE in build_unary_op on field with
counted_by attribute
Product: gcc
Version: 17.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: kacper.slominski72 at gmail dot com
Target Milestone: ---
The following code (reduced from Linux 7.0.11), when compiled with `gcc -c
bug.c -o bug.o` causes an ICE in build_unary_op:
struct {
int b;
int *a __attribute__((__counted_by__(b)));
} c;
void d() {
!c.a;
}
The error and stack trace is as follows:
bug.c: In function ādā:
bug.c:7:9: internal compiler error: in build_unary_op, at c/c-typeck.cc:5797
7 | !c.a;
| ^
0x55ddcaa2d084 internal_error(char const*, ...)
/usr/src/debug/sys-devel/gcc-17.0.9999/gcc-17.0.9999/gcc/diagnostic-global-context.cc:787
0x55ddc87dc031 fancy_abort(char const*, int, char const*)
/usr/src/debug/sys-devel/gcc-17.0.9999/gcc-17.0.9999/gcc/diagnostics/context.cc:1813
0x55ddc8404f26 build_unary_op(unsigned long, tree_code, tree_node*, bool)
/usr/src/debug/sys-devel/gcc-17.0.9999/gcc-17.0.9999/gcc/c/c-typeck.cc:5797
0x55ddc88468df parser_build_unary_op(unsigned long, tree_code, c_expr)
/usr/src/debug/sys-devel/gcc-17.0.9999/gcc-17.0.9999/gcc/c/c-typeck.cc:5064
0x55ddc887d82d c_parser_unary_expression
/usr/src/debug/sys-devel/gcc-17.0.9999/gcc-17.0.9999/gcc/c/c-parser.cc:10745
0x55ddc887f7be c_parser_cast_expression
/usr/src/debug/sys-devel/gcc-17.0.9999/gcc-17.0.9999/gcc/c/c-parser.cc:10656
0x55ddc887fb1b c_parser_binary_expression
/usr/src/debug/sys-devel/gcc-17.0.9999/gcc-17.0.9999/gcc/c/c-parser.cc:10420
0x55ddc888123f c_parser_conditional_expression
/usr/src/debug/sys-devel/gcc-17.0.9999/gcc-17.0.9999/gcc/c/c-parser.cc:10110
0x55ddc8881bf9 c_parser_expr_no_commas
/usr/src/debug/sys-devel/gcc-17.0.9999/gcc-17.0.9999/gcc/c/c-parser.cc:10023
0x55ddc8881eee c_parser_expression
/usr/src/debug/sys-devel/gcc-17.0.9999/gcc-17.0.9999/gcc/c/c-parser.cc:14253
0x55ddc88ad8fd c_parser_expression_conv
/usr/src/debug/sys-devel/gcc-17.0.9999/gcc-17.0.9999/gcc/c/c-parser.cc:14312
0x55ddc88ad8fd c_parser_statement_after_labels
/usr/src/debug/sys-devel/gcc-17.0.9999/gcc-17.0.9999/gcc/c/c-parser.cc:8558
0x55ddc88b22bc c_parser_compound_statement_nostart
/usr/src/debug/sys-devel/gcc-17.0.9999/gcc-17.0.9999/gcc/c/c-parser.cc:7958
0x55ddc88abe24 c_parser_compound_statement
/usr/src/debug/sys-devel/gcc-17.0.9999/gcc-17.0.9999/gcc/c/c-parser.cc:7172
0x55ddc88abe24 c_parser_declaration_or_fndef
/usr/src/debug/sys-devel/gcc-17.0.9999/gcc-17.0.9999/gcc/c/c-parser.cc:3354
0x55ddc88bd2d0 c_parser_external_declaration
/usr/src/debug/sys-devel/gcc-17.0.9999/gcc-17.0.9999/gcc/c/c-parser.cc:2256
0x55ddc88be0a3 c_parser_translation_unit
/usr/src/debug/sys-devel/gcc-17.0.9999/gcc-17.0.9999/gcc/c/c-parser.cc:2095
0x55ddc88be0a3 c_parse_file()
/usr/src/debug/sys-devel/gcc-17.0.9999/gcc-17.0.9999/gcc/c/c-parser.cc:31409
0x55ddc89599f0 c_common_parse_file()
/usr/src/debug/sys-devel/gcc-17.0.9999/gcc-17.0.9999/gcc/c-family/c-opts.cc:1430
/usr/libexec/gcc/x86_64-pc-linux-gnu/17/cc1 -quiet bug.c -quiet -dumpbase bug.c
-dumpbase-ext .c -mtune=generic -march=x86-64 -mtls-dialect=gnu2
-foffload-options=-fno-stack-protector -fcf-protection
-foffload-options=-fcf-protection=none -o /tmp/ccrmuuuc.s
gcc version:
gcc (Gentoo 17.0.9999 p, commit 683f23b7ee2e59bae5c0ac0fc39ff49566dbdacb)
17.0.0 20260604 (experimental) ff3ae0cd90e5d6e9347c467ec8881781779171e2