title: Swift: String.fromCString() didn't work sometimes
body: <p>Environment: Xcode 7.2.1 , Swift 2.1.1, OS X 10.11.3.</p>
  
  <p>First I create an osx project (Cocoa Application) using Xcode;</p>
  
  <p>Then I add a simple c++ file like below:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;string&gt;
  
  extern "C"{
  const char* test() {
      //std::string abc = "abc";
      //std::string abc = "abcdeabcde";
      //std::string abc = "abcdeabcdeabcde";
      std::string abc = "abcdefghijklmnopqrstuvwxyabcdefghijklmnopqrstuvwxyabcdefghijklmnopqrstuvwxyabcdefghijklmnopqrstuvwxyabcdefghijklmnopqrstuvwxyabcdefghijklmnopqrstuvwxyabcdefghijklmnopqrstuvwxyabcdefghijklmnopqrstuvwxyabcdefghijklmnopqrstuvwxyabcdefghijklmnopqrstuvwxyabcdefghijklmnopqrstuvwxyabcdefghijklmnopqrstuvwxyabcdefghijklmnopqrstuvwxyabcdefghijklmnopqrstuvwxyabcdefghijklmnopqrstuvwxyabcdefghijklmnopqrstuvwxyabcdefghijklmnopqrstuvwxyabcdefghijklmnopqrstuvwxyabcdefghijklmnopqrstuvwxyabcdefghijklmnopqrstuvwxyabcdefghijklmnopqrstuvwxyabcdefghijklmnopqrstuvwxyabcdefghijklmnopqrstuvwxyabcdefghijklmnopqrstuvwxyabcdefghijklmnopqrstuvwxyabcdefghijklmnopqrstuvwxyabcdefghijklmnopqrstuvwxyabcdefghijklmnopqrstuvwxyabcdefghijklmnopqrstuvwxyabcdefghijklmnopqrstuvwxyabcdefghijklmnopqrstuvwxyabcdefghijklmnopqrstuvwxyabcdefghijklmnopqrstuvwxyabcdefghijklmnopqrstuvwxyabcdefghijklmnopqrstuvwxyabcdefghijklmnopqrstuvwxy";
  
      return abc.data();
  }
  }
  </code></pre>
  
  <p>And, I call <code>test()</code> method at my <code>AppDelegate.swift</code> through <code>CStringTest-Bridging-Header.h</code>:</p>
  
  <pre><code>func applicationDidFinishLaunching(aNotification: NSNotification) {
      // Insert code here to initialize your application
      let origin = test()
      let convertResult = String.fromCString(origin)
      print(convertResult!)
  }
  </code></pre>
  
  <p>The result of 4 string value in cpp file is shown below:</p>
  
  <ol>
  <li><strong>success</strong>, result is: abc </li>
  <li><strong>error</strong>, result is: abciݿ</li>
  <li><strong>error</strong>, the <code>convertResult</code> is nil, and the console will tell you "fatal error: unexpectedly found nil while unwrapping an Optional value"</li>
  <li><strong>sometimes success</strong>, print the super long string just like it defined, and the other print nothing</li>
  </ol>
  
  <p>I search on Google and StackOverFlow all the day, and find anything about this bug.</p>