title: Objective C++ Crash on C++ String Array Append
body: <p>The following Objective C++ routine, if I run it enough in XCode 7.1 on OS X 10.11, eventually crashes on the string append. The debugger shows me that it stops every time at the number 23 (trying to append the number 23). I imagine this has to do with memory allocation. What am I doing wrong?</p>
  
  <p>The debugger opens the string class and jams on the return statement below. In the other debugger window it says (lldb), whatever that means.</p>
  
  <pre class="lang-cpp prettyprint-override"><code>template &lt;class _CharT, class _Traits, class _Allocator&gt;
  inline _LIBCPP_INLINE_VISIBILITY
  basic_string&lt;_CharT, _Traits, _Allocator&gt;&amp;
  basic_string&lt;_CharT, _Traits, _Allocator&gt;::append(const basic_string&amp; __str)
  {
      return append(__str.data(), __str.size());
  }
  </code></pre>
  
  <p>Here's my code I'm running that seems to cause the crash if I run the routine enough times. (This was only present during monkey testing, where I clicked on my Settings menu in my Objective C/C++ application enough times that it triggered the following function enough times to crash.)</p>
  
  <pre class="lang-cpp prettyprint-override"><code>std::string Minutes[] = {};
  std::string s = "";
  for (int i = 1; i&lt;= 59; i++) {
      s = std::to_string(i);
      if (s.length() &lt; 2) {
          s = "0" + s;
      }
      s = ":" + s;
      Minutes-&gt;append(s);
  }
  </code></pre>
  
  <p>This might be a plain old C++ question, perhaps not an Objective C++ question. Or, perhaps this is an Apple bug?</p>
  
  <p>Note that I ran an experiment with the following change, and it <strong>never crashed</strong> after 3 attempts of 100 times:</p>
  
  <pre class="lang-cpp prettyprint-override"><code>std::string Minutes[] = {};
  std::string s = "";
  for (int i = 1; i&lt;= 59; i++) {
      //s = std::to_string(i);
      /*
      if (s.length() &lt; 2) {
          s = "0" + s;
      }
      s = ":" + s;
      */
      //[Minutes-&gt;append(s);
      Minutes-&gt;append("01");
  }
  </code></pre>
  
  <p>Also, the following patch of code also runs 3 times, up to 100 times, without an issue:</p>
  
  <pre class="lang-cpp prettyprint-override"><code>const std::string Days[] = {"Su","M","T","W","Th","F","Sa"};
  std::string Hours[] = {};
  for (int i = 1; i &lt;= 12; i++) {
      Hours-&gt;append(std::to_string(i));
  }
  </code></pre>