https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69801
Bug ID: 69801 Summary: gcc ICE on valid code on x86_64-linux-gnu in "operand_equal_p" Product: gcc Version: 6.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: helloqirun at gmail dot com Target Milestone: --- The following valid code causes an ICE when compiled with the current gcc trunk on x86_64-linux-gnu in both 32-bit and 64-bit modes. (*) But a nearly identical case can pass. $ gcc-trunk -v Using built-in specs. COLLECT_GCC=gcc-trunk COLLECT_LTO_WRAPPER=/home/absozero/trunk/root-gcc/libexec/gcc/x86_64-pc-linux-gnu/6.0.0/lto-wrapper Target: x86_64-pc-linux-gnu Configured with: ../gcc/configure --prefix=/home/absozero/trunk/root-gcc --enable-languages=c,c++ --disable-werror --enable-multilib Thread model: posix gcc version 6.0.0 20160212 (experimental) [trunk revision 233377] (GCC) $ gcc-trunk abc.c -c abc.c: In function 'fn1': abc.c:5:1: internal compiler error: in operand_equal_p, at fold-const.c:2776 void fn1() { e ? (d ? b : c).c : (d ? b : c).c; } ^~~~ 0x872dc5 operand_equal_p(tree_node const*, tree_node const*, unsigned int) ../../gcc/gcc/fold-const.c:2776 0x871c2e operand_equal_p(tree_node const*, tree_node const*, unsigned int) ../../gcc/gcc/fold-const.c:2982 0x872378 operand_equal_p(tree_node const*, tree_node const*, unsigned int) ../../gcc/gcc/fold-const.c:3123 0x8714c6 operand_equal_p(tree_node const*, tree_node const*, unsigned int) ../../gcc/gcc/fold-const.c:3067 0x8711ca operand_equal_p(tree_node const*, tree_node const*, unsigned int) ../../gcc/gcc/fold-const.c:3091 0xf5ff61 generic_simplify_COND_EXPR /home/absozero/trunk/build-gcc/gcc/generic-match.c:26035 0xf5ff61 generic_simplify(unsigned int, tree_code, tree_node*, tree_node*, tree_node*, tree_node*) /home/absozero/trunk/build-gcc/gcc/generic-match.c:26273 0x87e93c fold_ternary_loc(unsigned int, tree_code, tree_node*, tree_node*, tree_node*, tree_node*) ../../gcc/gcc/fold-const.c:11406 0x880ee3 fold_build3_stat_loc(unsigned int, tree_code, tree_node*, tree_node*, tree_node*, tree_node*) ../../gcc/gcc/fold-const.c:12506 0x68b7e3 c_fully_fold_internal ../../gcc/gcc/c/c-fold.c:506 0x68cd4b c_fully_fold(tree_node*, bool, bool*) ../../gcc/gcc/c/c-fold.c:90 0x629a0f c_process_expr_stmt(unsigned int, tree_node*) ../../gcc/gcc/c/c-typeck.c:10231 0x629e0d c_finish_expr_stmt(unsigned int, tree_node*) ../../gcc/gcc/c/c-typeck.c:10276 0x6770d0 c_parser_statement_after_labels ../../gcc/gcc/c/c-parser.c:5275 0x678d5b c_parser_compound_statement_nostart ../../gcc/gcc/c/c-parser.c:4859 0x6795de c_parser_compound_statement ../../gcc/gcc/c/c-parser.c:4695 0x675144 c_parser_declaration_or_fndef ../../gcc/gcc/c/c-parser.c:2107 0x68089d c_parser_external_declaration ../../gcc/gcc/c/c-parser.c:1551 0x6812c9 c_parser_translation_unit ../../gcc/gcc/c/c-parser.c:1429 0x6812c9 c_parse_file() ../../gcc/gcc/c/c-parser.c:17826 Please submit a full bug report, with preprocessed source if appropriate. Please include the complete backtrace with any bug report. See <http://gcc.gnu.org/bugs.html> for instructions. $ cat abc.c struct { char c[1]; } b, c; int d, e; void fn1() { e ? (d ? b : c).c : (d ? b : c).c; } A nearly identical case: $ diff abc.c a.c 5c5 < void fn1() { e ? (d ? b : c).c : (d ? b : c).c; } --- > void fn1() { e ? (d ? b : c).c : (e ? b : c).c; } $ gcc-trunk a.c -c Syntactically, variables d and e should be treated in the same way.