http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58845
Bug ID: 58845 Summary: Operator || and && broken for vectors Product: gcc Version: 4.9.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: reichelt at gcc dot gnu.org The following (IMHO valid) code snippet triggers an ICE since GCC 4.8.0 when compiled with "-O": ========================================== void foo() { int v __attribute__((vector_size(8))); v = v || v; } ========================================== bug.cc: In function 'void foo()': bug.cc:4:12: internal compiler error: in build_int_cst_wide, at tree.c:1258 v = v || v; ^ 0xd213b3 build_int_cst_wide(tree_node*, unsigned long, long) ../../gcc/gcc/tree.c:1258 0xd216f0 double_int_to_tree(tree_node*, double_int) ../../gcc/gcc/tree.c:1112 0xd2173a build_int_cst(tree_node*, long) ../../gcc/gcc/tree.c:1089 0x9348c3 make_range(tree_node*, int*, tree_node**, tree_node**, bool*) ../../gcc/gcc/fold-const.c:4217 0x939952 fold_range_test ../../gcc/gcc/fold-const.c:4980 0x939952 fold_truth_andor ../../gcc/gcc/fold-const.c:8619 0x8fd0d8 fold_binary_loc(unsigned int, tree_code, tree_node*, tree_node*, tree_node*) ../../gcc/gcc/fold-const.c:12769 0x93f57c fold(tree_node*) ../../gcc/gcc/fold-const.c:14648 0x68901a cp_build_binary_op(unsigned int, tree_code, tree_node*, tree_node*, int) ../../gcc/gcc/cp/typeck.c:4920 0x556b5c build_new_op_1 ../../gcc/gcc/cp/call.c:5468 0x5576a7 build_new_op(unsigned int, tree_code, int, tree_node*, tree_node*, tree_node*, tree_node**, int) ../../gcc/gcc/cp/call.c:5513 0x677762 build_x_binary_op(unsigned int, tree_code, tree_node*, tree_code, tree_node*, tree_code, tree_node**, int) ../../gcc/gcc/cp/typeck.c:3752 0x651545 cp_parser_binary_expression ../../gcc/gcc/cp/parser.c:7877 0x6517af cp_parser_assignment_expression ../../gcc/gcc/cp/parser.c:7996 0x651c04 cp_parser_assignment_expression ../../gcc/gcc/cp/parser.c:8046 0x651c04 cp_parser_constant_expression ../../gcc/gcc/cp/parser.c:8256 0x65193c cp_parser_assignment_expression ../../gcc/gcc/cp/parser.c:8015 0x653c93 cp_parser_expression ../../gcc/gcc/cp/parser.c:8158 0x65449e cp_parser_expression ../../gcc/gcc/cp/parser.c:8197 0x65449e cp_parser_expression_statement ../../gcc/gcc/cp/parser.c:9488 Please submit a full bug report, [etc.] Without "-O" I get the following (IMHO bogus) error message: bug.cc: In function 'void foo()': bug.cc:4:5: error: cannot convert 'bool' to '__vector(2) int' in assignment v = v || v; ^ And in fact, if I modify the testcase according to the error message, I get another ICE: ================================================ void foo() { int v __attribute__((vector_size(8))); bool b = v || v; } ================================================ bug.cc: In function 'void foo()': bug.cc:1:6: error: vector comparison returning a boolean void foo() ^ vector(2) int vector(2) int if (v != { 0, 0 }) goto <D.2218>; else goto <D.2221>; bug.cc:1:6: error: vector comparison returning a boolean vector(2) int vector(2) int if (v != { 0, 0 }) goto <D.2218>; else goto <D.2219>; bug.cc:1:6: internal compiler error: verify_gimple failed 0xb4007f verify_gimple_in_seq(gimple_statement_d*) ../../gcc/gcc/tree-cfg.c:4368 0x9854fc gimplify_body(tree_node*, bool) ../../gcc/gcc/gimplify.c:8799 0x985806 gimplify_function_tree(tree_node*) ../../gcc/gcc/gimplify.c:8884 0x81f4c7 analyze_function ../../gcc/gcc/cgraphunit.c:636 0x8207b4 analyze_functions ../../gcc/gcc/cgraphunit.c:1002 0x821ce9 finalize_compilation_unit() ../../gcc/gcc/cgraphunit.c:2260 0x625cc0 cp_write_global_declarations() ../../gcc/gcc/cp/decl2.c:4438 Please submit a full bug report, [etc.] Btw, the same happens for the operator &&.