<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 --- - stringbuf randomly changes get area"
href="http://llvm.org/bugs/show_bug.cgi?id=15446">15446</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>stringbuf randomly changes get area
</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>john@johnmaddock.co.uk
</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>The following code is a reduced test case of what boost::lexical_cast does
internally when converting a string to a number type. It fails with libc++
Trunk (and Clang Trunk) because stringbuf's get area gets changed during
operator>> :
#include <sstream>
#include <cassert>
template< class BufferType, class CharT >
class stl_buf_unlocker: public BufferType{
public:
typedef BufferType base_class;
CharT* pptr() const { return base_class::pptr(); }
CharT* pbase() const { return base_class::pbase(); }
void setg(CharT* gbeg, CharT* gnext, CharT* gend){ return
base_class::setg(gbeg, gnext, gend); }
void setp(CharT* pbeg, CharT* pend) { return setp(pbeg, pend); }
};
int main(int argc, char** argv)
{
typedef stl_buf_unlocker<std::stringbuf, char> unlocked_but_t;
const char* p = "3.141592653589793238462";
//
// Internally boost::lexical_cast casts away the constantness and plays a
little fast
// and loose with the buffer type in order to set the get buffer area:
//
std::istringstream is;
char* start = const_cast<char*>(p);
char* finish = start + std::strlen(start);
static_cast<unlocked_but_t*>(is.rdbuf())->setg(start, start, finish);
long double d;
is >> d;
//char c = is.get();
assert(is.rdbuf()->in_avail() == 0);
return 0;
}
This is currently causing a lot of Boost.Math code to fail</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>