From 75b6c99e2c704b3e366ce86020633c517a821d61 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Thu, 24 Jun 2021 16:40:40 -0700 Subject: [PATCH] defMAC construction up a scope to make it live long enough. (#54702) Fixes #54649 --- src/coreclr/jit/morph.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/coreclr/jit/morph.cpp b/src/coreclr/jit/morph.cpp index 6d7f8c7..e53c2d9 100644 --- a/src/coreclr/jit/morph.cpp +++ b/src/coreclr/jit/morph.cpp @@ -6046,6 +6046,10 @@ GenTree* Compiler::fgMorphField(GenTree* tree, MorphAddrContext* mac) } #endif + // Create a default MorphAddrContext early so it doesn't go out of scope + // before it is used. + MorphAddrContext defMAC(MACK_Ind); + /* Is this an instance data member? */ if (objRef) @@ -6136,7 +6140,6 @@ GenTree* Compiler::fgMorphField(GenTree* tree, MorphAddrContext* mac) // NULL mac means we encounter the GT_FIELD first. This denotes a dereference of the field, // and thus is equivalent to a MACK_Ind with zero offset. - MorphAddrContext defMAC(MACK_Ind); if (mac == nullptr) { mac = &defMAC; -- 2.7.4