diff --git a/src/engine/frames.h b/src/engine/frames.h index 8904eefc95..07285f6ef0 100644 --- a/src/engine/frames.h +++ b/src/engine/frames.h @@ -103,6 +103,7 @@ struct module_scope_in_function private: FRAME * module_frame = nullptr; + module_t * saved_module = nullptr; }; }} // namespace b2::jam diff --git a/src/engine/function.cpp b/src/engine/function.cpp index 86bbf05b95..f2887c7648 100644 --- a/src/engine/function.cpp +++ b/src/engine/function.cpp @@ -5380,8 +5380,7 @@ b2::jam::module_scope_in_function::module_scope_in_function( FRAME * frame_, const char * module_name_) : module_frame(frame_) { - auto stack = stack_global(); - stack->push(b2::ensure_valid(module_frame->module)); + saved_module = b2::ensure_valid(module_frame->module); module_frame->module = module_name_ == nullptr ? b2::ensure_valid(root_module()) : b2::ensure_valid(bindmodule(value_ref(module_name_))); @@ -5389,8 +5388,7 @@ b2::jam::module_scope_in_function::module_scope_in_function( b2::jam::module_scope_in_function::~module_scope_in_function() { - auto stack = stack_global(); - module_frame->module = b2::ensure_valid(stack->pop()); + module_frame->module = b2::ensure_valid(saved_module); } std::string b2::jam::backtrace::to_string(frame * f)