title: Unlogical C6001 warning: Using uninitialized memory warning in C with Visual Studio
body: <p>Given this code:</p>
  
  <pre class="lang-c prettyprint-override"><code>#include &lt;stdlib.h&gt;
  
  typedef struct
  {
      int *p;
  } MyStruct;
  
  MyStruct Test()
  {
      MyStruct ms;
      ms.p = malloc(sizeof(int) * 5);
      if (!ms.p) exit(-1);
      return ms;
  }
  
  int main(void)
  {
      while (1)
      {
          MyStruct t = Test();
          free(t.p); // C6001: Using uninitialized memory 't.p'.
      }
  }
  </code></pre>
  
  <p>Visual Studio shows C6001 warning on the <code>free</code> call line. However, I see there is no way to achieve the free line with the memory t.p uninitialized. What am I missing ?</p>
  
  <p><a href="https://i.stack.imgur.com/SJsJ1.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/SJsJ1.png" alt="enter image description here"></a></p>