<html>
<head>
<base href="https://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 --- - codecvt<wchar_t, char, std::mbstate_t>::do_out does not set from_next and to_next correctly on error"
href="https://llvm.org/bugs/show_bug.cgi?id=27937">27937</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>codecvt<wchar_t, char, std::mbstate_t>::do_out does not set from_next and to_next correctly on error
</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>FreeBSD
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>All Bugs
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>roel@abittechnical.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org, mclow.lists@gmail.com
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>Created <span class=""><a href="attachment.cgi?id=16436" name="attach_16436" title="Program that reproduces the issue">attachment 16436</a> <a href="attachment.cgi?id=16436&action=edit" title="Program that reproduces the issue">[details]</a></span>
Program that reproduces the issue
I've noticed that our software when building on Mac OS X or FreeBSD with libc++
has a failing test due to std::codecvt<wchar_t, char, std::mbstate_t>::do_out
not properly assigning from_next and to_next when it returns
std::codecvt<wchar_t, char, std::mbstate_t>::error.
I don't have a copy of the final standard, but the draft specification of C++14
I found (<a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4296.pdf">http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4296.pdf</a>)
says that "It always leaves the from_next and to_next pointers pointing one
beyond the last element successfully converted" in ยง22.4.1.4.2.
If my interpretation of that specification is correct, then I think it's
supposed to convert as many characters as it can and set from_next and to_next
to one position past the last correctly converted character. This is also the
behavior of libstdc++ and MSVC. However, with libc++, from_next and to_next are
placed back in their original position.
I attached a test program that reproduces the issue. The expected output is:
Error!
pwc is now at position: 7
pc is now at position: 7
The actual output is:
Error!
pwc is now at position: 0
pc is now at position: 0</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>