On 1/11/26 6:24 AM, Patrick Palka wrote:
On Tue, 6 Jan 2026, Peter Damianov wrote:
When a local class has an NSDMI that references a static local variable
from the enclosing template function, we ICE during synthesized method
walking.
The issue is that r14-8981 added maybe_push_to_top_level in
synthesized_method_walk, which calls push_function_context for
function-local classes (non-lambdas). This clears current_function_decl.
But push_function_context clears cfun, not current_function_decl?
Ah, and then pop_function_context clobbers current_function_decl with
the saved cfun, which is NULL here. So the problem really seems to be
with pop_function_context assuming current_function_decl must agree with
cfun which isn't true in the C++ front end. (cfun is generally set when
parsing/processing a function, and current_function_decl is for
temporarily entering the scope of a function.)
Perhaps maybe_push/pop_top_level needs to save/restore
current_function_decl separately alongside calling
push/pop_function_context? Or maybe replace the push/pop_function_context
calls with our own saving/restoring of cfun? Wonder what Jason thinks.
This was fixed in a different way by r16-7034-g4652ca53fcbf01 so I think
this patch is no longer needed. Thanks for the analysis.
Jason