[LLVMbugs] [Bug 21361] New: ostream::seekp() not standard-compliant

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Thu Oct 23 12:23:11 PDT 2014


http://llvm.org/bugs/show_bug.cgi?id=21361

            Bug ID: 21361
           Summary: ostream::seekp() not standard-compliant
           Product: libc++
           Version: 3.4
          Hardware: PC
                OS: MacOS X
            Status: NEW
          Severity: normal
          Priority: P
         Component: All Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: lavr at ncbi.nlm.nih.gov
                CC: llvmbugs at cs.uiuc.edu, mclow.lists at gmail.com
    Classification: Unclassified

Hello,

We're using Cland 3.4.0 with _LIBCPP_VERSION 1101, and ran into a problem
that a stream that has only a eofbit set in its state cannot be positioned
with any of the seekp() methods.  Upon a closer view, it turned out
that the LIBCPP's implementation builds a sentry object (which is another
way of checking for good(), basically), but the standard (both old and new)
says that "fail() != true" is the only prerequisite for the calls to work.

In case of only the eofbit set, good() != true, but fail() != true, either.
So the sentry object fails, causing seekp() to fail in LIBCPP;  but it should
have worked.

A fix would be much appreciated.

Thanks,
Anton Lavrentiev


Here's the comparison of LIBCPP's and GCC's/MSVC's (both of which work
correctly, BTW) implemetations:


LIBCPP:
template <class _CharT, class _Traits>
inline _LIBCPP_INLINE_VISIBILITY
basic_ostream<_CharT, _Traits>&
basic_ostream<_CharT, _Traits>::seekp(off_type __off, ios_base::seekdir __dir)
{
    sentry __s(*this);
    if (__s)
    {
        if (this->rdbuf()->pubseekoff(__off, __dir, ios_base::out) ==
pos_type(-1))


GCC:
  template<typename _CharT, typename _Traits>
    basic_ostream<_CharT, _Traits>&
    basic_ostream<_CharT, _Traits>::
    seekp(off_type __off, ios_base::seekdir __dir)
    {
      ios_base::iostate __err = ios_base::goodbit;
      __try
        {
          if (!this->fail())
            {
              // _GLIBCXX_RESOLVE_LIB_DEFECTS
              // 136.  seekp, seekg setting wrong streams?
              const pos_type __p = this->rdbuf()->pubseekoff(__off, __dir,
                                                             ios_base::out);


MSVC:
    _Myt& __CLR_OR_THIS_CALL seekp(off_type _Off, ios_base::seekdir _Way)
        {    // change output stream position by _Off, according to _Way
        if (!ios_base::fail()
            && (off_type)_Myios::rdbuf()->pubseekoff(_Off, _Way,
                ios_base::out) == _BADOFF)

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20141023/3319d9f1/attachment.html>


More information about the llvm-bugs mailing list