https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102624
--- Comment #2 from qingzhe huang <nickhuang99 at hotmail dot com> --- (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 driver. 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 this "announce_function" below directory "cp" level because it might recurse itself and interleave with the set/reset "current_function_decl". Does anybody depend on the result of this "announce_function"? Driver? Plugin? 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. BTW, this issue is hidden by option "-quiet" because it suppresses "announce_function" output. #0 announce_function (decl=0x7ffff73ab700) at ../../gcc-10.2.0/gcc/toplev.c:230 #1 0x0000000000a03d26 in start_preparsed_function (decl1=0x7ffff73ab700, attrs=0x0, flags=3) at ../../gcc-10.2.0/gcc/cp/decl.c:16291 #2 0x0000000000a4cc75 in start_lambda_function (fco=0x7ffff73ab700, lambda_expr=0x7ffff7399cc0) at ../../gcc-10.2.0/gcc/cp/lambda.c:1425 #3 0x0000000000b25f8f in tsubst_lambda_expr (t=0x7ffff7399480, args=0x7ffff7383aa0, complain=0, in_decl=0x7ffff738b100) at ../../gcc-10.2.0/gcc/cp/pt.c:19086 #4 0x0000000000b2aa76 in tsubst_copy_and_build (t=0x7ffff7399480, args=0x7ffff7383aa0, complain=0, in_decl=0x0, function_p=false, integral_constant_expression_p=false) at ../../gcc-10.2.0/gcc/cp/pt.c:20511 #5 0x0000000000b1be1b in tsubst (t=0x7ffff739c000, args=0x7ffff7383aa0, complain=0, in_decl=0x0) at ../../gcc-10.2.0/gcc/cp/pt.c:15936 #6 0x0000000000a20637 in dump_template_bindings (pp=0x343cfc0 <actual_pretty_printer>, parms=0x0, args=0x7ffff7383aa0, typenames=0x7ffff73a67f8) at ../../gcc-10.2.0/gcc/cp/error.c:416 #7 0x0000000000a23b94 in dump_substitution (pp=0x343cfc0 <actual_pretty_printer>, t=0x7ffff726b400, template_parms=0x7ffff73827f8, template_args=0x7ffff7383aa0, flags=4) at ../../gcc-10.2.0/gcc/cp/error.c:1562 #8 0x0000000000a24622 in dump_function_decl (pp=0x343cfc0 <actual_pretty_printer>, t=0x7ffff726b400, flags=4) at ../../gcc-10.2.0/gcc/cp/error.c:1720 #9 0x0000000000a230b0 in dump_decl (pp=0x343cfc0 <actual_pretty_printer>, t=0x7ffff73a3300, flags=4) at ../../gcc-10.2.0/gcc/cp/error.c:1292 #10 0x0000000000a27805 in decl_as_string (decl=0x7ffff73a3300, flags=4) at ../../gcc-10.2.0/gcc/cp/error.c:2995 #11 0x0000000000a278dd in lang_decl_name (decl=0x7ffff73a3300, v=2, translate=false) at ../../gcc-10.2.0/gcc/cp/error.c:3029 #12 0x0000000000b78f8a in cxx_printable_name_internal (decl=0x7ffff73a3300, v=2, translate=false) at ../../gcc-10.2.0/gcc/cp/tree.c:2596 #13 0x0000000000b7900b in cxx_printable_name (decl=0x7ffff73a3300, v=2) at ../../gcc-10.2.0/gcc/cp/tree.c:2605 #14 0x000000000139c9cf in announce_function (decl=0x7ffff73a3300) at ../../gcc-10.2.0/gcc/toplev.c:236