title: C++ std string different between debug and release dynamic library
body: <p>I have a dynamic library in which I send an IP address and try to connect to an instrument. The library is working well when it's build in debug mode but crashes on using release one.</p>
  <p>I am trying to use it from a console application and this is what I have:</p>
  <p>Main in the console application</p>
  <pre><code>#define QT_API extern &quot;C&quot;  __declspec(dllimport)
  int main()
  {
  
      QT_InterfaceManager * manager = createInstance();
  
      cout &lt;&lt; &quot;Connect = &quot; &lt;&lt; bert_Connect(manager, &quot;172.16.109.113&quot;) &lt;&lt; endl;
  
      cin.get();
  
      return 0;
  }
  </code></pre>
  <p>Interface from my dll</p>
  <pre><code>#define QT_API extern &quot;C&quot;  __declspec(dllexport)
  #define STACKMODE   __stdcall
  
  QT_API bool STACKMODE bert_Connect(QT_InterfaceManager * inst, std::string IP) {
  
      cout &lt;&lt; &quot;Received IP = &quot; &lt;&lt; IP &lt;&lt; endl;
      //  Do Something
  }
  </code></pre>
  <p>When using my function from a Debug library</p>
  <p><a href="https://i.stack.imgur.com/JuswE.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/JuswE.png" alt="IP when using Debug" /></a></p>
  <p>When using my function from a Release library</p>
  <p><a href="https://i.stack.imgur.com/sIeww.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/sIeww.png" alt="enter image description here" /></a></p>
  <p><a href="https://i.stack.imgur.com/OlU1r.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/OlU1r.png" alt="enter image description here" /></a></p>
  <p>What might cause such a difference in passing a simple std string</p>