title: Xcode 5.1 std::string concatenation crash on iOS 5.1 devices in release builds
body: <p>When built with the latest XCode 5.1, iOS SDK 7.1 and LLVM 5.1, using libstdc++ for the C++ standard library, get crash in the std::string <strong>append</strong> method only on iOS 5.1 device.</p>
  
  <p>Here's code example:</p>
  
  <pre><code>class TestClass
  {
  public:
      TestClass()
      {
          m_string = "string1";
      }
  
      void AppendString()
      {
          m_string += std::string("string2");
          std::string newString2 = m_string + "string3";
      }
  
  private:
      string m_string;
  };
  </code></pre>
  
  <p>App crashes in <strong>AppendString()</strong> method on this line:</p>
  
  <pre><code>        std::string newString2 = m_string + "string3";
  </code></pre>
  
  <p>If I remove this line <code>m_string += std::string("string2");</code> before creating <strong>newString2</strong>, code works fine.</p>
  
  <p>Here's the stacktrace of crash:</p>
  
  <pre><code>#0  0x34c99fe8 in memcpy$VARIANT$CortexA8 ()
  #1  0x3706f95a in std::string::_Rep::_M_clone(std::allocator&lt;char&gt; const&amp;, unsigned long) ()
  #2  0x3706fbfa in std::string::reserve(unsigned long) ()
  #3  0x3706fdb0 in std::string::append(char const*, unsigned long) ()
  #4  0x000c0e5a in std::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; std::operator+&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;(std::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; const&amp;, char const*) [inlined] at /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.1.sdk/usr/include/c++/4.2.1/bits/basic_string.h:2121
  #5  0x000c0e3c in TestClass::AppendString() at /Users/sergei/Documents/2_3/House of Fun/cpp/CasinoSceneManager.cpp:122
  </code></pre>
  
  <p>Have anybody experinced same crash? It happens only on devices with iOS 5.1 and 5.1.1 and only if app was compiled with <strong>release</strong> flag, not <strong>debug</strong>.</p>
  
  <p>Thank you for the help.</p>
  
  <hr>
  
  <p>One more note. 
  If I change <strong>Optimization level</strong> to <strong>None [-O0]</strong> in <strong>Code Generation</strong> section in project settings, everything works fine. 
  Maybe the problem has some connection to code optimization.</p>