https://llvm.org/bugs/show_bug.cgi?id=23266
Bug ID: 23266
Summary: raw_svector_ostream::pwrite problems
Product: new-bugs
Version: trunk
Hardware: PC
OS: Windows NT
Status: NEW
Severity: normal
Priority: P
Component: new bugs
Assignee: [email protected]
Reporter: [email protected]
CC: [email protected], [email protected]
Classification: Unclassified
Hi Rafael,
Try adding this to the raw_pwrite_stream_test.cpp unit test, which will fail.
SmallString<16> Buffer4;
raw_svector_ostream OS4(Buffer4);
OS4.pwrite(Test.data(), Test.size(), 0);
OS4 << '4';
StringRef S4 = OS4.str();
EXPECT_EQ(S4, "4est");
While raw_fd_ostream::pwrite is careful to keep the current position so you can
do random r/w without disturbing the current stream position,
raw_svector_ostream::pwrite does not keep it, assuming the currrent position is
the vector size. Thus any write after pwrite will always occur at the end of
the vector and following the previous write(), inconsistent with
raw_svector_ostream::pwrite and programmer expectation.
Furthermore, the code
if (End > OS.size())
OS.resize(End);
must call resync() as it may modify the OS vector without updating the pointers
OutBufStart, OutBufEnd and OutBufCur.
These problems cause sometime corrupt ELF object file when written into a
raw_svector_ostream instead of raw_fd_ostream.
--
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs