https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115554
Bug ID: 115554 Summary: RISC-V: ICE in case of multiple target-arch attributes Product: gcc Version: 15.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: target Assignee: unassigned at gcc dot gnu.org Reporter: cmuellner at gcc dot gnu.org Target Milestone: --- Minimal reproducers (for target-arch): extern __attribute__((target("arch=+zba"))) __attribute__((target("arch=+zbb"))) void foo(void); extern __attribute__((target("arch=+zbb"))) __attribute__((target("arch=+zbb"))) void bar(void); The ICE is a bug. If multiple target-arch attributes should not be allowed, then an error message is the right solution. Allowing multiple target-X attributes is problematic, as can be seen for baz(). I.e., does the second attribute amend or replace the previous one? However, accepting multiple target-X attributes if they are equal (like for bar) could be done. The assertion was added in the GCC 14 cycle (commit 9941f0295a1). GCC 14 and 15 are affected. GCC 13 is not affected (we don't have RISC-V target-arch attributes in GCC 13). The ICE looks like this: $ riscv64-unknown-linux-gnu-gcc bar.c -c bar.c:4:1: internal compiler error: in riscv_func_target_put, at common/config/riscv/riscv-common.cc:521 4 | void foo(void); | ^~~~ 0xc15306 riscv_func_target_put(tree_node*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >) /home/cm/src/gcc/riscv-mainline/gcc/common/config/riscv/riscv-common.cc:521 0x18234d3 riscv_process_target_attr /home/cm/src/gcc/riscv-mainline/gcc/config/riscv/riscv-target-attr.cc:370 0x182334c riscv_process_target_attr /home/cm/src/gcc/riscv-mainline/gcc/config/riscv/riscv-target-attr.cc:314 0x182363d riscv_option_valid_attribute_p(tree_node*, tree_node*, tree_node*, int) /home/cm/src/gcc/riscv-mainline/gcc/config/riscv/riscv-target-attr.cc:389 0xd560ee handle_target_attribute /home/cm/src/gcc/riscv-mainline/gcc/c-family/c-attribs.cc:5915 0xc24d04 decl_attributes(tree_node**, tree_node*, int, tree_node*) /home/cm/src/gcc/riscv-mainline/gcc/attribs.cc:900 0xc2bbed c_decl_attributes /home/cm/src/gcc/riscv-mainline/gcc/c/c-decl.cc:5501 0xc43b77 start_decl(c_declarator*, c_declspecs*, bool, tree_node*, bool, unsigned int*) /home/cm/src/gcc/riscv-mainline/gcc/c/c-decl.cc:5647 0xcb4d73 c_parser_declaration_or_fndef /home/cm/src/gcc/riscv-mainline/gcc/c/c-parser.cc:2773 0xcc158b c_parser_external_declaration /home/cm/src/gcc/riscv-mainline/gcc/c/c-parser.cc:2053 0xcc1fb5 c_parser_translation_unit /home/cm/src/gcc/riscv-mainline/gcc/c/c-parser.cc:1907 0xcc1fb5 c_parse_file() /home/cm/src/gcc/riscv-mainline/gcc/c/c-parser.cc:27303 0xd3b9c1 c_common_parse_file() /home/cm/src/gcc/riscv-mainline/gcc/c-family/c-opts.cc:1322