From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id BE3D03858406; Mon, 22 Nov 2021 17:40:20 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BE3D03858406 From: "jakub at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/103329] [11/12 Regression] Code divergence in debug info with -fdump-tree-original since r11-291-g0f50f6daa140186a Date: Mon, 22 Nov 2021 17:40:20 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 12.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: jakub at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 11.3 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: cc Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 22 Nov 2021 17:40:20 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D103329 Jakub Jelinek changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jakub at gcc dot gnu.org --- Comment #3 from Jakub Jelinek --- The problem seems that in order to print the *.original dump (but apparently also in order to emit some warnings), we trigger: #0 used_types_insert (t=3D) at ../../gcc/function.c:6422 #1 0x0000000000c26eb6 in mark_used (decl=3D, complain=3D0) at ../../gcc/cp/decl2.c:5681 #2 0x0000000000dee6f0 in tsubst_qualified_id (qualified_id=3D, args=3D, complain=3D0, in_decl=3D= ,=20 done=3Dtrue, address_p=3Dfalse) at ../../gcc/cp/pt.c:16460 #3 0x0000000000e03d01 in tsubst_copy_and_build (t=3D, args=3D, complain=3D0, in_decl=3D,=20 function_p=3Dfalse, integral_constant_expression_p=3Dtrue) at ../../gcc/cp/pt.c:20046 #4 0x0000000000e0041a in tsubst_expr (t=3D, args=3D, complain=3D0, in_decl=3D,=20 integral_constant_expression_p=3Dtrue) at ../../gcc/cp/pt.c:19228 #5 0x0000000000dd88cf in tsubst_template_arg (t=3D, args=3D, complain=3D0, in_decl=3D) at ../../gcc/cp/pt.c:12342 #6 0x0000000000ddcca6 in tsubst_template_args (t=3D, args=3D, complain=3D0, in_decl=3D) at ../../gcc/cp/pt.c:13433 #7 0x0000000000ddd9e7 in tsubst_aggr_type (t=3D, args=3D, complain=3D0, in_decl=3D,=20 entering_scope=3D0) at ../../gcc/cp/pt.c:13637 #8 0x0000000000deaa22 in tsubst (t=3D, args=3D, complain=3D0, in_decl=3D) at ../../gcc/cp/pt.c:15527 #9 0x0000000000de7c32 in tsubst_decl (t=3D, args=3D, complain=3D0) at ../../gcc/cp/pt.c:14825 #10 0x0000000000dea26e in tsubst (t=3D, args=3D, complain=3D0, in_decl=3D) at ../../gcc/cp/pt.c:15447 #11 0x0000000000e0ac1c in instantiate_template_1 (tmpl=3D, orig_args=3D, complai= n=3D0) at ../../gcc/cp/pt.c:21337 #12 0x0000000000e0b2f2 in instantiate_template (tmpl=3D, orig_args=3D, complai= n=3D0) at ../../gcc/cp/pt.c:21396 #13 0x0000000000e0b466 in instantiate_alias_template (tmpl=3D, args=3D, complain=3D0= ) at ../../gcc/cp/pt.c:21434 #14 0x0000000000dea49d in tsubst (t=3D, args=3D, complain=3D0, in_decl=3D) at ../../gcc/cp/pt.c:15472 #15 0x0000000000c2e7e1 in dump_template_bindings (pp=3D0x3e0c5a0 , parms=3D, args=3D, typenames=3D0x7fffea1dbd98 =3D {...}) at ../../gcc/cp/error.c:482 #16 0x0000000000c34a2f in dump_substitution (pp=3D0x3e0c5a0 , t=3D, template_parms=3D,=20 template_args=3D, flags=3D4) at ../../gcc/cp/error.c:1638 #17 0x0000000000c365d1 in dump_function_decl (pp=3D0x3e0c5a0 , t=3D, flags=3D4)= at ../../gcc/cp/error.c:1797 #18 0x0000000000c33917 in dump_decl (pp=3D0x3e0c5a0 , t=3D, flags=3D4) at ../../gcc/cp/error.c:= 1369 #19 0x0000000000c3cf88 in decl_as_string (decl=3D, flags=3D4) at ../../gcc/cp/error.c:3118 #20 0x0000000000c3d060 in lang_decl_name (decl=3D, v=3D2, translate=3Dfalse) at ../../gcc/cp/error.c:3153 #21 0x0000000000e8b59f in cxx_printable_name_internal (decl=3D, v=3D2, translate=3Dfalse) at ../../gcc/cp/tree.c:2678 #22 0x0000000000e8b63c in cxx_printable_name (decl=3D, v=3D2) at ../../gcc/cp/tree.c:2687 #23 0x0000000000f4f4c3 in c_genericize (fndecl=3D) at ../../gcc/c-family/c-gimplify.c:587 where when trying to print the pow decl into the dump file, we instantiate = the template and that leads to adding the anonymous enum to types_used_by_cur_var_decl vector (or attached to current function). Later on we do in cp_finish_decl 8260 /* So decl is a global variable or a static member of a 8261 non local class. Record the types it uses 8262 so that we can decide later to emit debug info for them.= */ 8263 record_types_used_by_current_var_decl (decl); and attach those types to a random unrelated decl (a guard variable in this case). Similarly, without -fdump-tree-original and without -w, we trigger it durin= g: #0 used_types_insert (t=3D) at ../../gcc/function.c:6422 #1 0x0000000000c26eb6 in mark_used (decl=3D, complain=3D0) at ../../gcc/cp/decl2.c:5681 #2 0x0000000000dee6f0 in tsubst_qualified_id (qualified_id=3D, args=3D, complain=3D0, in_decl=3D= ,=20 done=3Dtrue, address_p=3Dfalse) at ../../gcc/cp/pt.c:16460 #3 0x0000000000e03d01 in tsubst_copy_and_build (t=3D, args=3D, complain=3D0, in_decl=3D,=20 function_p=3Dfalse, integral_constant_expression_p=3Dtrue) at ../../gcc/cp/pt.c:20046 #4 0x0000000000e0041a in tsubst_expr (t=3D, args=3D, complain=3D0, in_decl=3D,=20 integral_constant_expression_p=3Dtrue) at ../../gcc/cp/pt.c:19228 #5 0x0000000000dd88cf in tsubst_template_arg (t=3D, args=3D, complain=3D0, in_decl=3D) at ../../gcc/cp/pt.c:12342 #6 0x0000000000ddcca6 in tsubst_template_args (t=3D, args=3D, complain=3D0, in_decl=3D) at ../../gcc/cp/pt.c:13433 #7 0x0000000000ddd9e7 in tsubst_aggr_type (t=3D, args=3D, complain=3D0, in_decl=3D,=20 entering_scope=3D0) at ../../gcc/cp/pt.c:13637 #8 0x0000000000deaa22 in tsubst (t=3D, args=3D, complain=3D0, in_decl=3D) at ../../gcc/cp/pt.c:15527 #9 0x0000000000de7c32 in tsubst_decl (t=3D, args=3D, complain=3D0) at ../../gcc/cp/pt.c:14825 #10 0x0000000000dea26e in tsubst (t=3D, args=3D, complain=3D0, in_decl=3D) at ../../gcc/cp/pt.c:15447 #11 0x0000000000e0ac1c in instantiate_template_1 (tmpl=3D, orig_args=3D, complai= n=3D0) at ../../gcc/cp/pt.c:21337 #12 0x0000000000e0b2f2 in instantiate_template (tmpl=3D, orig_args=3D, complai= n=3D0) at ../../gcc/cp/pt.c:21396 #13 0x0000000000e0b466 in instantiate_alias_template (tmpl=3D, args=3D, complain=3D0= ) at ../../gcc/cp/pt.c:21434 #14 0x0000000000dea49d in tsubst (t=3D, args=3D, complain=3D0, in_decl=3D) at ../../gcc/cp/pt.c:15472 #15 0x0000000000c2e7e1 in dump_template_bindings (pp=3D0x3e0c5a0 , parms=3D, args=3D, typenames=3D0x7fffea1dbd98 =3D {...}) at ../../gcc/cp/error.c:482 #16 0x0000000000c34a2f in dump_substitution (pp=3D0x3e0c5a0 , t=3D, template_parms=3D,=20 template_args=3D, flags=3D132) at ../../gcc/cp/error.c:1638 #17 0x0000000000c365d1 in dump_function_decl (pp=3D0x3e0c5a0 , t=3D, flags=3D13= 2) at ../../gcc/cp/error.c:1797 #18 0x0000000000c33917 in dump_decl (pp=3D0x3e0c5a0 , t=3D, flags=3D132) at ../../gcc/cp/error.= c:1369 #19 0x0000000000c3d5ab in decl_to_string (decl=3D, verbose=3D1) at ../../gcc/cp/error.c:3217 #20 0x0000000000c41255 in cp_printer (pp=3D0x3fff130, text=3D0x7fffffffce90, spec=3D0x4001452 "D", precision=3D0, wide=3Dfalse, set_locus=3Dfalse, verbo= se=3Dtrue, quoted=3D0x7fffffffcaaf,=20 buffer_ptr=3D0x4001240) at ../../gcc/cp/error.c:4388 #21 0x0000000002d5af22 in pp_format (pp=3D0x3fff130, text=3D0x7fffffffce90)= at ../../gcc/pretty-print.c:1475 #22 0x0000000002d5b2fa in pp_format_verbatim (pp=3D0x3fff130, text=3D0x7fffffffce90) at ../../gcc/pretty-print.c:1536 #23 0x0000000002d5bb4e in pp_verbatim (pp=3D0x3fff130, msg=3D0x2e32238 "%s:= In instantiation of %q#D:\n") at ../../gcc/pretty-print.c:1790 #24 0x0000000000c3f369 in print_instantiation_full_context (context=3D0x3f9= bf40 ) at ../../gcc/cp/error.c:3627 #25 0x0000000000c3f86e in maybe_print_instantiation_context (context=3D0x3f= 9bf40 ) at ../../gcc/cp/error.c:3775 #26 0x0000000000c3deb3 in cp_diagnostic_starter (context=3D0x3f9bf40 , diagnostic=3D0x7fffffffd0a0) at ../../gcc/cp/error.c:3466 #27 0x0000000002d316bb in diagnostic_report_diagnostic (context=3D0x3f9bf40 , diagnostic=3D0x7fffffffd0a0) at ../../gcc/diagnostic.c:1347 #28 0x0000000002d31d9c in diagnostic_impl (richloc=3D0x7fffffffd270, metadata=3D0x0, opt=3D714, gmsgid=3D0x2e2b9a8 "no return statement in funct= ion returning non-void", ap=3D0x7fffffffd170,=20 kind=3DDK_WARNING) at ../../gcc/diagnostic.c:1508 #29 0x0000000002d3277e in warning_at (richloc=3D0x7fffffffd270, opt=3D714, gmsgid=3D0x2e2b9a8 "no return statement in function returning non-void") at ../../gcc/diagnostic.c:1660 I wonder if the error.c spots that trigger tsubst shouldn't temporarily set some FE global flag that would either cause if (TREE_CODE (decl) =3D=3D CONST_DECL) used_types_insert (DECL_CONTEXT (decl)); in mark_used not to happen, or perhaps the whole mark_used not to be done altogether?=