From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id BF5533858C60; Thu, 7 Oct 2021 10:46:56 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BF5533858C60 From: "nickhuang99 at hotmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/102624] testcase lambda-uneval11.C causes cc1plus segment fault Date: Thu, 07 Oct 2021 10:46:56 +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: ice-on-valid-code X-Bugzilla-Severity: normal X-Bugzilla-Who: nickhuang99 at hotmail dot com 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: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: 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: Thu, 07 Oct 2021 10:46:56 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D102624 --- Comment #2 from qingzhe huang --- (In reply to Richard Biener from comment #1) > so it looks like some diagnostics affect current_function_decl, the key > is omitting -quiet from the command-line that's usually added by the driv= er. That is absolutely correct. However, I think the real danger is the "announce_function" which is the root cause. The name and behavior makes it look like a harmless-readonly debug output. However, it is effectively doing not only recursing itself, but sidelines by calling "tsubt" which eventually set "current_function_decl" back-and-forth. So, my fix is to comment out th= is "announce_function" below directory "cp" level because it might recurse its= elf and interleave with the set/reset "current_function_decl".=20 Does anybody depend on the result of this "announce_function"? Driver? Plug= in?=20 Also I want to point out that any debug method using debug printf of format "%F" will suffer the similar issue because they are similar to "announce_function". I personally debug using a lot of this format and it drives me crazy when these seemingly-harmless print/warning function cause crash. Somebody needs to write some really "readonly" debug output helper functions for developers! I may prepare a patch if no objections.=20 BTW, this issue is hidden by option "-quiet" because it suppresses "announce_function" output. #0 announce_function (decl=3D0x7ffff73ab700) at ../../gcc-10.2.0/gcc/toplev.c:230 #1 0x0000000000a03d26 in start_preparsed_function (decl1=3D0x7ffff73ab700, attrs=3D0x0, flags=3D3) at ../../gcc-10.2.0/gcc/cp/decl.c:16291 #2 0x0000000000a4cc75 in start_lambda_function (fco=3D0x7ffff73ab700, lambda_expr=3D0x7ffff7399cc0) at ../../gcc-10.2.0/gcc/cp/lambda.c:1425 #3 0x0000000000b25f8f in tsubst_lambda_expr (t=3D0x7ffff7399480, args=3D0x7ffff7383aa0, complain=3D0,=20 in_decl=3D0x7ffff738b100) at ../../gcc-10.2.0/gcc/cp/pt.c:19086 #4 0x0000000000b2aa76 in tsubst_copy_and_build (t=3D0x7ffff7399480, args=3D0x7ffff7383aa0, complain=3D0, in_decl=3D0x0,=20 function_p=3Dfalse, integral_constant_expression_p=3Dfalse) at ../../gcc-10.2.0/gcc/cp/pt.c:20511 #5 0x0000000000b1be1b in tsubst (t=3D0x7ffff739c000, args=3D0x7ffff7383aa0, complain=3D0, in_decl=3D0x0) at ../../gcc-10.2.0/gcc/cp/pt.c:15936 #6 0x0000000000a20637 in dump_template_bindings (pp=3D0x343cfc0 , parms=3D0x0,=20 args=3D0x7ffff7383aa0, typenames=3D0x7ffff73a67f8) at ../../gcc-10.2.0/gcc/cp/error.c:416 #7 0x0000000000a23b94 in dump_substitution (pp=3D0x343cfc0 , t=3D0x7ffff726b400,=20 template_parms=3D0x7ffff73827f8, template_args=3D0x7ffff7383aa0, flags= =3D4) at ../../gcc-10.2.0/gcc/cp/error.c:1562 #8 0x0000000000a24622 in dump_function_decl (pp=3D0x343cfc0 , t=3D0x7ffff726b400, flags=3D4) at ../../gcc-10.2.0/gcc/cp/error.c:1720 #9 0x0000000000a230b0 in dump_decl (pp=3D0x343cfc0 , t=3D0x7ffff73a3300, flags=3D4) at ../../gcc-10.2.0/gcc/cp/error.c:1292 #10 0x0000000000a27805 in decl_as_string (decl=3D0x7ffff73a3300, flags=3D4)= at ../../gcc-10.2.0/gcc/cp/error.c:2995 #11 0x0000000000a278dd in lang_decl_name (decl=3D0x7ffff73a3300, v=3D2, translate=3Dfalse) at ../../gcc-10.2.0/gcc/cp/error.c:3029 #12 0x0000000000b78f8a in cxx_printable_name_internal (decl=3D0x7ffff73a330= 0, v=3D2, translate=3Dfalse) at ../../gcc-10.2.0/gcc/cp/tree.c:2596 #13 0x0000000000b7900b in cxx_printable_name (decl=3D0x7ffff73a3300, v=3D2)= at ../../gcc-10.2.0/gcc/cp/tree.c:2605 #14 0x000000000139c9cf in announce_function (decl=3D0x7ffff73a3300) at ../../gcc-10.2.0/gcc/toplev.c:236=