https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84171

            Bug ID: 84171
           Summary: [8 Regression] ICE with -Wsign-compare
           Product: gcc
           Version: 8.0
            Status: UNCONFIRMED
          Keywords: error-recovery, ice-on-invalid-code
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: reichelt at gcc dot gnu.org
                CC: jason at gcc dot gnu.org
  Target Milestone: ---

The following invalid code snippet triggers an ICE on trunk if compiled
with -Wsign-compare (included in -Wall):

=================================
bool foo (char c)
{
  const int i = 0 = 0;
  return c = i;
}
=================================

bug.cc: In function 'bool foo(char)':
bug.cc:3:21: error: lvalue required as left operand of assignment
   const int i = 0 = 0;
                     ^
bug.cc:4:14: internal compiler error: tree check: expected class 'type', have
'exceptional' (error_mark) in warn_for_sign_compare, at c-family/c-warn.c:1926
   return c = i;
              ^
0x788cda tree_class_check_failed(tree_node const*, tree_code_class, char
const*, int, char const*)
        ../../gcc/gcc/tree.c:9375
0x689286 tree_class_check(tree_node*, tree_code_class, char const*, int, char
const*)
        ../../gcc/gcc/tree.h:3255
0x689286 warn_for_sign_compare(unsigned int, tree_node*, tree_node*,
tree_node*, tree_node*, tree_node*, tree_code)
        ../../gcc/gcc/c-family/c-warn.c:1926
0x9dae42 cp_build_binary_op(unsigned int, tree_code, tree_node*, tree_node*,
int)
        ../../gcc/gcc/cp/typeck.c:5324
0x86e4c1 ocp_convert(tree_node*, tree_node*, int, int, int)
        ../../gcc/gcc/cp/cvt.c:812
0x86fa1e cp_convert(tree_node*, tree_node*, int)
        ../../gcc/gcc/cp/cvt.c:623
0x86fa1e cp_convert_and_check(tree_node*, tree_node*, int)
        ../../gcc/gcc/cp/cvt.c:642
0x81de78 convert_like_real
        ../../gcc/gcc/cp/call.c:7111
0x81eb5f perform_implicit_conversion_flags(tree_node*, tree_node*, int, int)
        ../../gcc/gcc/cp/call.c:10574
0x9e22aa check_return_expr(tree_node*, bool*)
        ../../gcc/gcc/cp/typeck.c:9371
0x99cf2e finish_return_stmt(tree_node*)
        ../../gcc/gcc/cp/semantics.c:890
0x91a054 cp_parser_jump_statement
        ../../gcc/gcc/cp/parser.c:12368
0x91a054 cp_parser_statement
        ../../gcc/gcc/cp/parser.c:10773
0x91add0 cp_parser_statement_seq_opt
        ../../gcc/gcc/cp/parser.c:11218
0x91aea7 cp_parser_compound_statement
        ../../gcc/gcc/cp/parser.c:11172
0x931630 cp_parser_function_body
        ../../gcc/gcc/cp/parser.c:21710
0x931630 cp_parser_ctor_initializer_opt_and_function_body
        ../../gcc/gcc/cp/parser.c:21747
0x931ee0 cp_parser_function_definition_after_declarator
        ../../gcc/gcc/cp/parser.c:26648
0x932bf7 cp_parser_function_definition_from_specifiers_and_declarator
        ../../gcc/gcc/cp/parser.c:26564
0x932bf7 cp_parser_init_declarator
        ../../gcc/gcc/cp/parser.c:19436
Please submit a full bug report, [etc.]

Jason, the regression started with your patch
https://gcc.gnu.org/viewcvs?rev=249083&root=gcc&view=rev

Would you mind having a look?

Reply via email to