stdcxx-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Liviu Nicoara <>
Subject std::strstreambuf fails to correctly set stream position
Date Wed, 03 May 2006 20:37:27 GMT

The following test case fails with the latest dev stdcxx (*):

tmp$ cat t.cpp

#include <assert.h>

#include <iosfwd>
#include <strstream>

int main ()
    std::strstreambuf sb;
    std::ostream  os (&sb);

    os << " ";
    std::streampos pos =
        sb.pubseekoff (0, std::ios::end, std::ios::out);
    assert (pos == 1);

    return 0;

I ran it in an 11s build on Linux and it asserts - pos is coming back as
128 (coincidentally the size of our implementation's buffer, 16 for gcc,
512 for aCC, 128 for SunPro).

The reason for this seems to be D.7.1 p4:

"Each object of class strstreambuf has a seekable area, delimited by the
pointers seeklow and seekhigh. If gnext is a null pointer, the seekable
area is undefined. *Otherwise, seeklow equals gbeg and seekhigh is
either pend, if pend is not a null pointer, or gend.*"

The specification for seekhi seems to be incorrect - seekhi should be
the last initialized character in the controlled sequence.


(*) The failure is also present in GNU libstdc++ (gcc 4.1.0), SunPro's
C++ Standard Library (5.3 through 5.8), HP aCC 3.63's stdlib but not
Dinkumware (AIX 5.3 w/ VisualAge for C++ 8.0, Windows XP w/ MSVC 7.1 and

View raw message