Quiet warning C2220
authorJoseph Tremoulet <jotrem@microsoft.com>
Mon, 22 May 2017 21:27:30 +0000 (17:27 -0400)
committerJoseph Tremoulet <JCTremoulet@gmail.com>
Mon, 22 May 2017 23:49:24 +0000 (19:49 -0400)
This warning reports "potentially uninitialized local variable
`fieldOffset` used".  The use is guarded by a check on `fieldHnd` being
non-null, and `fieldOffset` gets initialized properly on all paths that
set `fieldHnd` to something other than null, so the fix is simply to
initialize `fieldOffset` to 0 at its declaration so the compiler won't
complain.

Resolves #11800.

src/jit/morph.cpp

index 74ecb28..086d469 100644 (file)
@@ -18062,7 +18062,7 @@ GenTreePtr Compiler::fgMorphImplicitByRefArgs(GenTreePtr tree, bool isAddr)
     LclVarDsc* lclVarDsc  = &lvaTable[lclNum];
 
     CORINFO_FIELD_HANDLE fieldHnd;
-    unsigned             fieldOffset;
+    unsigned             fieldOffset  = 0;
     var_types            fieldRefType = TYP_UNKNOWN;
 
     if (lvaIsImplicitByRefLocal(lclNum))