http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58207
Bug ID: 58207 Summary: ICE in sort_constexpr_mem_initializers due to out of bounds vector access Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: tsaunders at mozilla dot com Created attachment 30680 --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=30680&action=edit preprocessed and somewhat reduced test case The attached test case causes an ICE after errors with xg++ (GCC) 4.9.0 20130817 (experimental) as well as with g++ 4.8.0 but not with g++ 4.7.2 #0 diagnostic_report_diagnostic (context=0x1823300 <global_diagnostic_context>, diagnostic=diagnostic@entry=0x7fffffffda00) at ../../gcc/gcc/diagnostic.c:757 location = 3464477 orig_diag_kind = DK_ICE saved_format_spec = <optimized out> #1 0x0000000000ffbf80 in internal_error (gmsgid=gmsgid@entry=0x13e2d6b "in %s, at %s:%d") at ../../gcc/gcc/diagnostic.c:1127 diagnostic = {message = {format_spec = 0x13e2d6b "in %s, at %s:%d", args_ptr = 0x7fffffffd9e8, err_no = 2, locus = 0x7ffff6974093 <__GI___libc_malloc+99>, x_data = 0x0}, location = 3464477, override_column = 0, x_data = 0x0, kind = DK_ICE, option_index = 0} ap = {{gp_offset = 8, fp_offset = 48, overflow_arg_area = 0x7fffffffdb00, reg_save_area = 0x7fffffffda40}} __FUNCTION__ = "internal_error" #2 0x0000000000ffa7f4 in fancy_abort (file=file@entry=0x109f4c0 "../../gcc/gcc/vec.h", line=line@entry=827, function=function@entry=0x10cf8a0 <_ZZN3vecI17constructor_elt_d5va_gc8vl_embedEixEjE12__FUNCTION__> "operator[]") at ../../gcc/gcc/diagnostic.c:1181 No locals. #3 0x00000000006be2b8 in vec<constructor_elt_d, va_gc, vl_embed>::operator[] (ix=0, this=<optimized out>) at ../../gcc/gcc/vec.h:827 No locals. #4 0x00000000006d6427 in operator[] (ix=<optimized out>, this=<optimized out>) at ../../gcc/gcc/tree.h:4111 No locals. #5 build_constexpr_constructor_member_initializers (body=<optimized out>, type=0x7ffff5337bd0) at ../../gcc/gcc/cp/semantics.c:6207 vec = 0x7ffff5376e58 ok = <optimized out> #6 massage_constexpr_body (fun=fun@entry=0x7ffff53c5300, body=body@entry=0x7ffff53bbb10) at ../../gcc/gcc/cp/semantics.c:6280 __FUNCTION__ = "massage_constexpr_body" #7 0x00000000006ddbb4 in register_constexpr_fundef (fun=fun@entry=0x7ffff53c5300, body=0x7ffff53bbb10) at ../../gcc/gcc/cp/semantics.c:6384 entry = {decl = 0x7ffff53c5300, body = 0x2} slot = <optimized out> __FUNCTION__ = "register_constexpr_fundef" #8 0x000000000057c058 in maybe_save_function_definition (fun=<optimized out>) at ../../gcc/gcc/cp/decl.c:13761 No locals. #9 finish_function (flags=flags@entry=3) at ../../gcc/gcc/cp/decl.c:13882 fndecl = 0x7ffff53c5300 fntype = 0x7ffff53c6000 ctype = 0x0 __FUNCTION__ = "finish_function" inclass_inline = 1 #10 0x00000000006643be in cp_parser_function_definition_after_declarator (parser=parser@entry=0x7ffff68d40b0, inline_p=inline_p@entry=true) at ../../gcc/gcc/cp/parser.c:22275 fn = <optimized out> ctor_initializer_p = true saved_in_unbraced_linkage_specification_p = false saved_in_function_body = false saved_num_template_parameter_lists = 0 #11 0x000000000064a09d in cp_parser_late_parsing_for_member (member_function=<optimized out>, parser=0x7ffff68d40b0) at ../../gcc/gcc/cp/parser.c:22921 function_scope = 0x0 tokens = 0x7ffff538cbc0 #12 cp_parser_class_specifier_1 (parser=parser@entry=0x7ffff68d40b0) at ../../gcc/gcc/cp/parser.c:19014 decl = <optimized out> pushed_scope = <optimized out> e = <optimized out> class_type = <optimized out> ix = 3 nested_name_specifier_p = <optimized out> saved_num_template_parameter_lists = <optimized out> saved_in_function_body = <optimized out> saved_in_unbraced_linkage_specification_p = <optimized out> scope = <optimized out> type = <optimized out> in_switch_statement_p = <optimized out> __FUNCTION__ = "cp_parser_class_specifier_1" attributes = <optimized out> in_statement = <optimized out> old_scope = <optimized out> closing_brace = <optimized out> #13 0x000000000064c211 in cp_parser_class_specifier (parser=0x7ffff68d40b0) at ../../gcc/gcc/cp/parser.c:19038 ret = <optimized out> #14 cp_parser_type_specifier (parser=parser@entry=0x7ffff68d40b0, flags=flags@entry=1, decl_specs=decl_specs@entry=0x7fffffffdf00, is_declaration=is_declaration@entry=true, declares_class_or_enum=declares_class_or_enum@entry=0x7fffffffde7c, is_cv_qualifier=is_cv_qualifier@entry=0x7fffffffde7b) at ../../gcc/gcc/cp/parser.c:14040 type_spec = 0x0 keyword = <optimized out> ds = ds_last #15 0x00000000006616ca in cp_parser_decl_specifier_seq (parser=parser@entry=0x7ffff68d40b0, flags=flags@entry=1, decl_specs=decl_specs@entry=0x7fffffffdf00, declares_class_or_enum=declares_class_or_enum@entry=0x7fffffffdefc) at ../../gcc/gcc/cp/parser.c:11283 decl_spec_declares_class_or_enum = 0 is_cv_qualifier = false type_spec = <optimized out> found_decl_spec = true __FUNCTION__ = "cp_parser_decl_specifier_seq" constructor_possible_p = <optimized out> start_token = <optimized out> ds = ds_last #16 0x00000000006651aa in cp_parser_simple_declaration (parser=parser@entry=0x7ffff68d40b0, function_definition_allowed_p=function_definition_allowed_p@entry=true, maybe_range_for_decl=maybe_range_for_decl@entry=0x0) at ../../gcc/gcc/cp/parser.c:10873 decl_specifiers = {locations = {0 <repeats 22 times>}, type = 0x0, attributes = 0x0, std_attributes = 0x0, redefined_builtin_type = 0x0, storage_class = sc_none, type_definition_p = 0, multiple_types_p = 0, conflicting_specifiers_p = 0, any_specifiers_p = 0, any_type_specifiers_p = 0, explicit_int_p = 0, explicit_int128_p = 0, explicit_char_p = 0, gnu_thread_keyword_p = 0} declares_class_or_enum = 0 saw_declarator = <optimized out> __FUNCTION__ = "cp_parser_simple_declaration" #17 0x00000000006671b1 in cp_parser_block_declaration (parser=0x7ffff68d40b0, statement_p=<optimized out>) at ../../gcc/gcc/cp/parser.c:10822 statement_p = <optimized out> parser = 0x7ffff68d40b0 #18 0x000000000067022c in cp_parser_declaration (parser=parser@entry=0x7ffff68d40b0) at ../../gcc/gcc/cp/parser.c:10719 token1 = <optimized out> saved_pedantic = 0 token2 = <optimized out> p = 0x18dba00 attributes = <optimized out> #19 0x000000000066eefe in cp_parser_declaration_seq_opt (parser=parser@entry=0x7ffff68d40b0) at ../../gcc/gcc/cp/parser.c:10605 No locals. #20 0x000000000066f111 in cp_parser_namespace_body (parser=0x7ffff68d40b0) at ../../gcc/gcc/cp/parser.c:15528 No locals. #21 cp_parser_namespace_definition (parser=0x7ffff68d40b0) at ../../gcc/gcc/cp/parser.c:15509 attribs = 0x0 __FUNCTION__ = "cp_parser_namespace_definition" identifier = 0x7ffff6875058 has_visibility = false is_inline = false #22 0x000000000067019e in cp_parser_declaration (parser=parser@entry=0x7ffff68d40b0) at ../../gcc/gcc/cp/parser.c:10707 token1 = {type = <optimized out>, keyword = RID_NAMESPACE, flags = <optimized out>, pragma_kind = <optimized out>, implicit_extern_c = <optimized out>, ambiguous_p = <optimized out>, purged_p = <optimized out>, location = <optimized out>, u = {tree_check_value = <optimized out>, value = <optimized out>}} saved_pedantic = 0 token2 = {type = CPP_NAME, keyword = RID_MAX, flags = <optimized out>, pragma_kind = <optimized out>, implicit_extern_c = <optimized out>, ambiguous_p = <optimized out>, purged_p = <optimized out>, location = <optimized out>, u = {tree_check_value = <optimized out>, value = <optimized out>}} p = 0x18dba00 attributes = 0x0 #23 0x000000000066eefe in cp_parser_declaration_seq_opt (parser=parser@entry=0x7ffff68d40b0) at ../../gcc/gcc/cp/parser.c:10605 No locals. #24 0x00000000006707b3 in cp_parser_translation_unit (parser=0x7ffff68d40b0) at ../../gcc/gcc/cp/parser.c:3930 success = <optimized out> declarator_obstack_base = 0x18dba00 #25 c_parse_file () at ../../gcc/gcc/cp/parser.c:28829 already_called = true #26 0x0000000000784375 in c_common_parse_file () at ../../gcc/gcc/c-family/c-opts.c:1046 i = 0 #27 0x0000000000af5c26 in compile_file () at ../../gcc/gcc/toplev.c:546 No locals. #28 0x0000000000af7a38 in do_compile () at ../../gcc/gcc/toplev.c:1878 No locals. #29 toplev_main (argc=3, argv=0x7fffffffe2b8) at ../../gcc/gcc/toplev.c:1954 No locals.