This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: libstdc++/6414: g++ 3.1 tellg() regression within last week


Missed a spot.  Testing now; I'll apply it to trunk and branch if it passes.

2002-04-23  Jason Merrill  <jason@redhat.com>

	PR libstdc++/6414
	* include/bits/fstream.tcc (basic_filebuf::seekoff): Adjust return
	value properly in the trivial case.
	* testsuite/27_io/istream_seeks.cc (test04): Make sure that
	tellg() returns the right value after a read.

Index: include/bits/fstream.tcc
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/include/bits/fstream.tcc,v
retrieving revision 1.30
diff -c -p -r1.30 fstream.tcc
*** include/bits/fstream.tcc	22 Apr 2002 20:28:04 -0000	1.30
--- include/bits/fstream.tcc	23 Apr 2002 12:55:24 -0000
*************** namespace std
*** 567,573 ****
  	  else
  	    {
  	      __ret = _M_file.seekoff(__off, ios_base::cur, __mode);
! 	      __ret += max(_M_out_cur, _M_in_cur) - _M_buf;
  	    }
  	}
        _M_last_overflowed = false;	
--- 567,573 ----
  	  else
  	    {
  	      __ret = _M_file.seekoff(__off, ios_base::cur, __mode);
! 	      __ret += _M_in_cur - _M_filepos;
  	    }
  	}
        _M_last_overflowed = false;	
Index: testsuite/27_io/istream_seeks.cc
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/testsuite/27_io/istream_seeks.cc,v
retrieving revision 1.10
diff -c -p -r1.10 istream_seeks.cc
*** testsuite/27_io/istream_seeks.cc	7 Aug 2001 03:38:33 -0000	1.10
--- testsuite/27_io/istream_seeks.cc	23 Apr 2002 12:55:25 -0000
*************** void test04(void)
*** 229,235 ****
    VERIFY( pos05 == pos06 + off_type(10) );
    VERIFY( state01 == state02 );
    pos06 = is03.tellg(); 
!   VERIFY( pos05 == pos06 ); 
  
  #ifdef DEBUG_ASSERT
    assert(test);
--- 229,242 ----
    VERIFY( pos05 == pos06 + off_type(10) );
    VERIFY( state01 == state02 );
    pos06 = is03.tellg(); 
!   VERIFY( pos05 == pos06 );
! 
!   // libstdc++/6414
!   if01.seekg(0, std::ios_base::beg);
!   pos01 = if01.tellg();
!   if01.peek();
!   pos02 = if01.tellg();
!   VERIFY( pos02 == pos01 );
  
  #ifdef DEBUG_ASSERT
    assert(test);

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]