Describe the bug
Currently, MSVC STL's basic_stringbuf relies on that the eback() pointer points to the beginning of the allocated buffer.
|
_Al.deallocate(_Ptr_traits::pointer_to(*_Mysb::eback()),
|
|
static_cast<typename allocator_traits<allocator_type>::size_type>(
|
|
(_Mysb::pptr() ? _Mysb::epptr() : _Mysb::egptr()) - _Mysb::eback()));
|
Likewise, basic_syncbuf requires pbase() to behave the same way.
|
_Getal().deallocate(_Refancy<_Pointer>(streambuf_type::pbase()), _Buf_size);
|
However, the pointers returned by these functions can be modified by users via setg/setp functions, which means these conditions can't be considered as invariants maintained by the implementation.
Command-line test case
|
# Not analyzed. Assertion failed: _CrtIsValidHeapPointer(block)
|
|
std/input.output/string.streams/stringbuf/stringbuf.members/str.pass.cpp FAIL
|
|
std/input.output/string.streams/stringbuf/stringbuf.members/view.pass.cpp FAIL
|
|
std/input.output/syncstream/syncbuf/syncstream.syncbuf.cons/dtor.pass.cpp FAIL
|
|
std/input.output/syncstream/syncbuf/syncstream.syncbuf.members/emit.pass.cpp FAIL
|
Expected behavior
These tests pass.
STL version
e077eb6
(Probably in all versions where basic_stringbuf or basic_syncbuf is available.)
Additional context
Not sure whether this can be fixed without breaking ABI. #4239 may be related, but doesn't fix any part of this issue.
Describe the bug
Currently, MSVC STL's
basic_stringbufrelies on that theeback()pointer points to the beginning of the allocated buffer.STL/stl/inc/sstream
Lines 495 to 497 in e077eb6
Likewise,
basic_syncbufrequirespbase()to behave the same way.STL/stl/inc/syncstream
Line 247 in e077eb6
However, the pointers returned by these functions can be modified by users via
setg/setpfunctions, which means these conditions can't be considered as invariants maintained by the implementation.Command-line test case
STL/tests/libcxx/expected_results.txt
Lines 1103 to 1107 in e077eb6
Expected behavior
These tests pass.
STL version
e077eb6
(Probably in all versions where
basic_stringbuforbasic_syncbufis available.)Additional context
Not sure whether this can be fixed without breaking ABI. #4239 may be related, but doesn't fix any part of this issue.