diff --git a/doc/interprocess.qbk b/doc/interprocess.qbk index 7787482..822bc41 100644 --- a/doc/interprocess.qbk +++ b/doc/interprocess.qbk @@ -6734,6 +6734,7 @@ thank them: [section:release_notes_boost_1_59_00 Boost 1.59 Release] * Fixed bugs: + * [@https://svn.boost.org/trac/boost/ticket/5139 ( Trac #5139 ( (['"Initial Stream Position in Boost.Interprocess.Vectorstream"])]. * [@https://github.com/boostorg/interprocess/pull/19 GitHub Pull #19 (['"Fix exception visibility"])]. Thanks to Romain-Geissler. [endsect] diff --git a/include/boost/interprocess/streams/bufferstream.hpp b/include/boost/interprocess/streams/bufferstream.hpp index 9a862e5..015d03c 100644 --- a/include/boost/interprocess/streams/bufferstream.hpp +++ b/include/boost/interprocess/streams/bufferstream.hpp @@ -200,8 +200,8 @@ class basic_bufferbuf if(!in && !out) return pos_type(off_type(-1)); - else if((in && (!(m_mode & std::ios_base::in) || this->gptr() == 0)) || - (out && (!(m_mode & std::ios_base::out) || this->pptr() == 0))) + else if((in && (!(m_mode & std::ios_base::in) || (off != 0 && this->gptr() == 0) )) || + (out && (!(m_mode & std::ios_base::out) || (off != 0 && this->pptr() == 0)))) return pos_type(off_type(-1)); std::streamoff newoff; diff --git a/include/boost/interprocess/streams/vectorstream.hpp b/include/boost/interprocess/streams/vectorstream.hpp index b6f873e..8f6bf38 100644 --- a/include/boost/interprocess/streams/vectorstream.hpp +++ b/include/boost/interprocess/streams/vectorstream.hpp @@ -298,8 +298,8 @@ class basic_vectorbuf return pos_type(off_type(-1)); else if((in && out) && (dir == std::ios_base::cur)) return pos_type(off_type(-1)); - else if((in && (!(m_mode & std::ios_base::in) || this->gptr() == 0)) || - (out && (!(m_mode & std::ios_base::out) || this->pptr() == 0))) + else if((in && (!(m_mode & std::ios_base::in) || (off != 0 && this->gptr() == 0) )) || + (out && (!(m_mode & std::ios_base::out) || (off != 0 && this->pptr() == 0)))) return pos_type(off_type(-1)); off_type newoff; diff --git a/test/bufferstream_test.cpp b/test/bufferstream_test.cpp index 7f82521..6b6cb24 100644 --- a/test/bufferstream_test.cpp +++ b/test/bufferstream_test.cpp @@ -34,6 +34,12 @@ static int bufferstream_test() //This will be zero-initialized static char buffer [BufSize]; bufferstream bufstream; + if(bufstream.tellg() != std::streampos(0)){ + return 1; + } + if(bufstream.tellp() != std::streampos(0)){ + return 1; + } std::stringstream std_stringstream; std::string str1, str2, str3("testline:"); int number1, number2; @@ -129,7 +135,7 @@ static int bufferstream_test() int main () { - if(bufferstream_test()==-1){ + if(bufferstream_test()){ return 1; } return 0; diff --git a/test/vectorstream_test.cpp b/test/vectorstream_test.cpp index e072ecd..d20b82a 100644 --- a/test/vectorstream_test.cpp +++ b/test/vectorstream_test.cpp @@ -39,6 +39,14 @@ static int vectorstream_test() { { //Test high watermarking initialization my_stringstream_t my_stringstream; + + if(my_stringstream.tellg() != std::streampos(0)){ + return 1; + } + if(my_stringstream.tellp() != std::streampos(0)){ + return 1; + } + int a (0); my_stringstream << 11; my_stringstream >> a;