title: C++ std::shared_ptr debug assertion failure
body: <p>I am studying the std::share_pointer with visual studio 2019 and I wrote a program just implements swapping two integers.</p>
  <pre><code>#include &lt;iostream&gt;
  #include &lt;memory&gt;
  
  void swap0(int* a, int* b)
  {
      int t = *a;
      *a = *b;
      *b = t;
  }
  
  void swap1(std::shared_ptr&lt;int&gt; a, std::shared_ptr&lt;int&gt; b)
  {
      int t = *a;
      *a = *b;
      *b = t;
  }
  
  int main()
  {
      int a = 10;
      int b = 20;
      std::cout &lt;&lt; a &lt;&lt; &quot; &quot; &lt;&lt; b &lt;&lt; std::endl; // 10 20
      std::shared_ptr&lt;int&gt; pa(&amp;a);
      std::shared_ptr&lt;int&gt; pb(&amp;b);
      swap1(pa, pb);
      std::cout &lt;&lt; a &lt;&lt; &quot; &quot; &lt;&lt; b &lt;&lt; std::endl; // 10 20
  }
  </code></pre>
  <p>But the program showed a dialog box titled Microsoft Visual C++ Runtime Library.
  Here's the information of the dialog box.</p>
  <pre><code>Debug Assertion Failed!
  Program:
  ....../ConsoleApplication1.exe
  File: minkernel\crts\ucrt\src\appcrt\heap\debug_heap.cpp
  Line: 904
  
  Express: _CrtIsValidHeapPointer(block)
  
  ......
  </code></pre>
  <p>Then I tried the same code with MinGW, The program was running normally.
  Did I abuse the shared_ptr?</p>