https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84310
Bug ID: 84310 Summary: -falign-{labels,loops,jumps} with value >= 32768+1 cause a segfault Product: gcc Version: unknown Status: UNCONFIRMED Keywords: ice-on-valid-code Severity: normal Priority: P3 Component: target Assignee: unassigned at gcc dot gnu.org Reporter: marxin at gcc dot gnu.org Target Milestone: --- All releases I have ICE: $ cat loop2.c void a () { for (;;) ; } void b () { for (;;) ; } $ valgrind --leak-check=yes --trace-children=yes ./xgcc -B. -O2 -S -o/dev/stdout loop2.c -falign-loops=32769 ==9402== Conditional jump or move depends on uninitialised value(s) ==9402== at 0xB87FB5: align_fuzz(rtx_def*, rtx_def*, int, unsigned int) (final.c:599) ==9402== by 0xB881C2: insn_current_reference_address(rtx_insn*) (final.c:661) ==9402== by 0x16EEAF0: insn_current_length(rtx_insn*) (i386.md:453) ==9402== by 0xB89C86: shorten_branches(rtx_insn*) (final.c:1448) ==9402== by 0xB90878: rest_of_handle_shorten_branches() (final.c:4728) ==9402== by 0xB908C8: (anonymous namespace)::pass_shorten_branches::execute(function*) (final.c:4757) ==9402== by 0xEBA842: execute_one_pass(opt_pass*) (passes.c:2497) ==9402== by 0xEBAB93: execute_pass_list_1(opt_pass*) (passes.c:2586) ==9402== by 0xEBABC4: execute_pass_list_1(opt_pass*) (passes.c:2587) ==9402== by 0xEBABC4: execute_pass_list_1(opt_pass*) (passes.c:2587) ==9402== by 0xEBAC1C: execute_pass_list(function*, opt_pass*) (passes.c:2597) ==9402== by 0xA3FC5D: cgraph_node::expand() (cgraphunit.c:2139) ==9402== ==9402== Use of uninitialised value of size 8 ==9402== at 0xA1AF52: INSN_UID(rtx_def*) (rtl.h:1423) ==9402== by 0xB87FC6: align_fuzz(rtx_def*, rtx_def*, int, unsigned int) (final.c:603) ==9402== by 0xB881C2: insn_current_reference_address(rtx_insn*) (final.c:661) ==9402== by 0x16EEAF0: insn_current_length(rtx_insn*) (i386.md:453) ==9402== by 0xB89C86: shorten_branches(rtx_insn*) (final.c:1448) ==9402== by 0xB90878: rest_of_handle_shorten_branches() (final.c:4728) ==9402== by 0xB908C8: (anonymous namespace)::pass_shorten_branches::execute(function*) (final.c:4757) ==9402== by 0xEBA842: execute_one_pass(opt_pass*) (passes.c:2497) ==9402== by 0xEBAB93: execute_pass_list_1(opt_pass*) (passes.c:2586) ==9402== by 0xEBABC4: execute_pass_list_1(opt_pass*) (passes.c:2587) ==9402== by 0xEBABC4: execute_pass_list_1(opt_pass*) (passes.c:2587) ==9402== by 0xEBAC1C: execute_pass_list(function*, opt_pass*) (passes.c:2597) ... Problem is that we have in shorten_branches set macro: #define MAX_CODE_ALIGN 16 which is then used for an array. Anyway similar to -malign-*: ./xgcc -B. -malign-functions=20 loop2.c cc1: warning: -malign-functions is obsolete, use -falign-functions cc1: error: -malign-functions=20 is not between 0 and 16 we should also limit the -falign-* options. Let me do it.