https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106616
Bug ID: 106616 Summary: ia64: ICE during RTL pass: mach: error: qsort comparator non-negative on sorted output: 3 Product: gcc Version: 13.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: target Assignee: unassigned at gcc dot gnu.org Reporter: slyfox at gcc dot gnu.org Target Milestone: --- Target: ia64-unknown-linux-gnu Observed this ICE on this week's ia64-gcc when was building linux4.19 for ia64 target. Here is extracted reproducer: // $ cat feat.c.c // /nix/store/pmvcr7vxqwi1jsykn0p9xw9446linswp-ia64-unknown-linux-gnu-stage-final-gcc-wrapper-13.0.0/bin/ia64-unknown-linux-gnu-gcc -O2 -c feat.c.c -o bug.o int inet_csk_schedule_ack(int); int dccp_feat_nn_get(int, int); struct sock_common; struct list_head { struct list_head *next; }; enum { DCCPF_SEQUENCE_WINDOW, DCCPF_ACK_RATIO }; struct dccp_sock { int dccps_inet_connection; struct list_head dccps_featneg; struct list_head node; } * dccp_feat_signal_nn_change_feat_entry; int dccp_feat_list_lookup_feat_num, dccp_feat_list_lookup_is_local, dccp_feat_is_valid_nn_val_feat_num, dccp_feat_is_valid_nn_val_val, dccp_feat_signal_nn_change_feat___trans_tmp_1; int dccp_feat_is_valid_nn_val(void) { switch (dccp_feat_is_valid_nn_val_feat_num) { case DCCPF_ACK_RATIO: return dccp_feat_is_valid_nn_val_val <= 5; case DCCPF_SEQUENCE_WINDOW: return dccp_feat_is_valid_nn_val_val <= 5ull; } return 0; } int dccp_feat_signal_nn_change_feat(struct sock_common *sk) { struct list_head *fn = &((struct dccp_sock *)sk)->dccps_featneg; if (!dccp_feat_is_valid_nn_val()) return 2; if (dccp_feat_nn_get((int)(long)sk, (int)(long)dccp_feat_signal_nn_change_feat)) return 0; char entry_0; dccp_feat_signal_nn_change_feat_entry = ({ (struct dccp_sock*)fn->next; }); for (; &dccp_feat_signal_nn_change_feat_entry->node == fn; dccp_feat_signal_nn_change_feat_entry = 0) if (entry_0 == dccp_feat_list_lookup_feat_num && dccp_feat_list_lookup_is_local) ; else if (entry_0 > dccp_feat_list_lookup_feat_num) dccp_feat_signal_nn_change_feat___trans_tmp_1 = 0; inet_csk_schedule_ack((int)(long)sk); return (int)(long)fn; } Crashing: $ ia64-unknown-linux-gnu-gcc -O2 -c feat.c.c -o bug.o -Wall feat.c.c: In function 'dccp_feat_signal_nn_change_feat': feat.c.c:41:17: warning: 'entry_0' may be used uninitialized [-Wmaybe-uninitialized] 41 | if (entry_0 == dccp_feat_list_lookup_feat_num && | ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ feat.c.c:37:8: note: 'entry_0' was declared here 37 | char entry_0; | ^~~~~~~ feat.c.c:48:1: error: qsort comparator non-negative on sorted output: 3 48 | } | ^ during RTL pass: mach feat.c.c:48:1: internal compiler error: qsort checking failed 0x187ff57 diagnostic_impl(rich_location*, diagnostic_metadata const*, int, char const*, __va_list_tag (*) [1], diagnostic_t) ???:0 0x1880da7 internal_error(char const*, ...) ???:0 0x7be301 qsort_chk_error(void const*, void const*, void const*, int (*)(void const*, void const*, void*), void*) ???:0 0x7be429 qsort_chk(void*, unsigned long, unsigned long, int (*)(void const*, void const*, void*), void*) [clone .cold] ???:0 0x18b46e8 gcc_qsort(void*, unsigned long, unsigned long, int (*)(void const*, void const*)) ???:0 0x16c6a27 ready_sort_real(ready_list*) [clone .constprop.0] ???:0 0x16ceb64 schedule_block(basic_block_def**, void*) ???:0 0x17a8b58 schedule_ebb(rtx_insn*, rtx_insn*, bool) ???:0 0x17a9149 schedule_ebbs() ???:0 0x1191baf ia64_reorg() ???:0 0xda5e49 (anonymous namespace)::pass_machine_reorg::execute(function*) ???:0 $ ia64-unknown-linux-gnu-gcc -v Using built-in specs. COLLECT_GCC=/<<NIX>>/ia64-unknown-linux-gnu-stage-final-gcc-13.0.0/bin/ia64-unknown-linux-gnu-gcc COLLECT_LTO_WRAPPER=/<<NIX>>/ia64-unknown-linux-gnu-stage-final-gcc-13.0.0/libexec/gcc/ia64-unknown-linux-gnu/13.0.0/lto-wrapper Target: ia64-unknown-linux-gnu Configured with: Thread model: posix Supported LTO compression algorithms: zlib gcc version 13.0.0 20220807 (experimental) (GCC)