<html>
    <head>
      <base href="http://llvm.org/bugs/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - std::vector + emplaced std::istringstream .seekg(0, std::ios_base::beg) leads to missize and trash at end of the stream .str()"
   href="http://llvm.org/bugs/show_bug.cgi?id=15659">15659</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>std::vector + emplaced std::istringstream .seekg(0, std::ios_base::beg) leads to missize and trash at end of the stream .str()
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>libc++
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>unspecified
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>release blocker
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>All Bugs
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>hhinnant@apple.com
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>iamtakingiteasy@eientei.org
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=10279" name="attach_10279" title="Example testcase">attachment 10279</a> <a href="attachment.cgi?id=10279&action=edit" title="Example testcase">[details]</a></span>
Example testcase

When std::istringstream emplaced into std::vector alongside with other
std::istringstream and then seeked to begening with .seekg(0,
std::ios_base::beg), it size becames largally bigger than original and end of
the stream filled with trash (probably, uninitalized or miss-accessed) data.

It is also known to work as expected on VC++ 2012.

The problem was reproduced with exact observed output by other person with
libc++.

Attaching a simple test-case; compiled with line

$ clang++ -std=c++11 -stdlib=libc++ tmp.cpp && ./a.out

Expected output:

3
MSG
3
31
hub started at [00 6b 8b 45 69]
31


Observed output:

3
MSG
3
31
hub started at [00 6b 8b 45 69]
593</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>