Bug 68362 - [6 Regression] ICE: tree check: expected integer_cst, have nop_expr in get_val, at tree.h:5157
Summary: [6 Regression] ICE: tree check: expected integer_cst, have nop_expr in get_va...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 6.0
: P3 normal
Target Milestone: 6.0
Assignee: Marek Polacek
URL:
Keywords:
: 68359 68364 (view as bug list)
Depends on:
Blocks:
 
Reported: 2015-11-15 16:33 UTC by Markus Trippelsdorf
Modified: 2015-11-16 20:20 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2015-11-16 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Markus Trippelsdorf 2015-11-15 16:33:48 UTC
trippels@gcc2-power8 generic % cat nsLineLayout.ii
enum class A { foo };
void fn1(const A test) {
  switch (test)
  case A::foo: ;
}

trippels@gcc2-power8 generic % g++ -c nsLineLayout.ii
nsLineLayout.ii: In function ‘void fn1(A)’:
nsLineLayout.ii:4:11: internal compiler error: tree check: expected integer_cst, have nop_expr in get_val, at tree.h:5157
   case A::foo: ;
           ^~~

0x10d9ee93 tree_check_failed(tree_node const*, char const*, int, char const*, ...)
        ../../gcc/gcc/tree.c:9587
0x10120d9b tree_int_cst_elt_check
        ../../gcc/gcc/tree.h:3144
0x104a9c8f tree_int_cst_elt_check
        ../../gcc/gcc/tree.h:3147
0x104a9c8f wi::extended_tree<192>::get_val() const
        ../../gcc/gcc/tree.h:5157
0x104a9c8f wi::int_traits<generic_wide_int<wi::extended_tree<192> > >::decompose(long*, unsigned int, generic_wide_int<wi::extended_tree<192> > const&)
        ../../gcc/gcc/wide-int.h:898
0x104a9c8f wide_int_ref_storage<generic_wide_int<wi::extended_tree<192> > >
        ../../gcc/gcc/wide-int.h:945
0x104a9c8f generic_wide_int<generic_wide_int<wi::extended_tree<192> > >
        ../../gcc/gcc/wide-int.h:722
0x104a9c8f lts_p<generic_wide_int<wi::extended_tree<192> >, generic_wide_int<wi::extended_tree<192> > >
        ../../gcc/gcc/wide-int.h:1749
0x104a9c8f tree_int_cst_lt
        ../../gcc/gcc/tree.h:5217
0x104a9c8f c_add_case_label(unsigned int, splay_tree_s*, tree_node*, tree_node*, tree_node*, tree_node*, bool*)
        ../../gcc/gcc/c-family/c-common.c:6592
0x1019f217 finish_case_label(unsigned int, tree_node*, tree_node*)
        ../../gcc/gcc/cp/decl.c:3417
0x102fb753 cp_parser_label_for_labeled_statement
        ../../gcc/gcc/cp/parser.c:10259
0x102e4ca3 cp_parser_statement
        ../../gcc/gcc/cp/parser.c:10132
0x1031e23b cp_parser_implicitly_scoped_statement
        ../../gcc/gcc/cp/parser.c:11557
0x102e56d3 cp_parser_selection_statement
        ../../gcc/gcc/cp/parser.c:10632
0x102e56d3 cp_parser_statement
        ../../gcc/gcc/cp/parser.c:10040
0x102e6617 cp_parser_statement_seq_opt
        ../../gcc/gcc/cp/parser.c:10456
0x102e67ef cp_parser_compound_statement
        ../../gcc/gcc/cp/parser.c:10410
0x1031325b cp_parser_function_body
        ../../gcc/gcc/cp/parser.c:20225
0x1031325b cp_parser_ctor_initializer_opt_and_function_body
        ../../gcc/gcc/cp/parser.c:20261
Comment 1 Markus Trippelsdorf 2015-11-15 18:54:43 UTC
*** Bug 68364 has been marked as a duplicate of this bug. ***
Comment 2 Markus Trippelsdorf 2015-11-16 06:49:51 UTC
Started with the delayed folding merge: r230365.
Comment 3 Richard Biener 2015-11-16 10:15:36 UTC
*** Bug 68368 has been marked as a duplicate of this bug. ***
Comment 4 Richard Biener 2015-11-16 10:19:39 UTC
*** Bug 68359 has been marked as a duplicate of this bug. ***
Comment 5 Marek Polacek 2015-11-16 14:26:11 UTC
The problem here is that check_case_bounds is getting NOP_EXPRs:
(const A) 0
introduced in convert_and_check called in c_add_case_label, and then it tries tree_int_cst_compare on that, oops.  STRIP_NOPS-ing case_low and case_high would fix this...
Comment 6 Marek Polacek 2015-11-16 20:17:28 UTC
Author: mpolacek
Date: Mon Nov 16 20:16:57 2015
New Revision: 230435

URL: https://gcc.gnu.org/viewcvs?rev=230435&root=gcc&view=rev
Log:
	PR c++/68362
	* c-common.c (check_case_bounds): Fold low and high cases.

	* g++.dg/delayedfold/switch-1.C: New test.

Added:
    trunk/gcc/testsuite/g++.dg/delayedfold/switch-1.C
Modified:
    trunk/gcc/c-family/ChangeLog
    trunk/gcc/c-family/c-common.c
    trunk/gcc/testsuite/ChangeLog
Comment 7 Marek Polacek 2015-11-16 20:20:28 UTC
Should be fixed now.