diff --git a/src/coreclr/jit/morph.cpp b/src/coreclr/jit/morph.cpp index 6d7f8c7bc6fdc..e53c2d9e8ff75 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;