title: EXC_BAD_ACCESS when calling stringstream and cleaning it
body: <p>I create a global variable:</p>
  
  <pre><code>stringstream ss(stringstream::in | stringstream::out);
  </code></pre>
  
  <p>Then with recursion my script is converting numbers to char:</p>
  
  <pre><code>ss &lt;&lt; Number;
  </code></pre>
  
  <p>and then to string:</p>
  
  <pre><code>Result = ss.str();
  </code></pre>
  
  <p>Function has many loops and recursion calls, I do use heuristics, but still I am converting variables to string many times. It works great when the function deals with small data, but when the data is larger, and there are thousands of loops and recursive calls I am getting this error: </p>
  
  <p>EXC_BAD_ACCESS (code=1 ....)</p>
  
  <p>Strangely, when I comment this:</p>
  
  <pre><code>ss.str(string());
  </code></pre>
  
  <p>The error is not there anymore. So it looks like this is the source of the error. But I need to clean the stream ss in order to make my script work correctly.</p>
  
  <p>EDIT:</p>
  
  <p>My compiler points the error to happen in <code>&lt;iosfwd&gt;</code></p>
  
  <pre><code>template &lt;class _CharT, class _Traits = char_traits&lt;_CharT&gt;,
            class _Allocator = allocator&lt;_CharT&gt; &gt;
      class _LIBCPP_TYPE_VIS_ONLY basic_stringstream;    &lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt; EXC_BAD_ACCESS
  </code></pre>
  
  <p><strong>EDIT (SOLUTION?):</strong>
  I decided to use this to convert int to strings:</p>
  
  <pre><code> Result +=  to_string(Number);
  </code></pre>
  
  <p>Which is not giving me any errors.</p>