Bug 16956 - [3.4 only] std::stringbuf::seekoff return wrong position value
Summary: [3.4 only] std::stringbuf::seekoff return wrong position value
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: libstdc++ (show other bugs)
Version: 3.4.1
: P2 normal
Target Milestone: 4.0.0
Assignee: Paolo Carlini
URL:
Keywords:
: 16957 16958 (view as bug list)
Depends on:
Blocks:
 
Reported: 2004-08-10 09:21 UTC by Sepherosa Ziehau
Modified: 2004-09-23 11:01 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2004-08-11 23:11:21


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Sepherosa Ziehau 2004-08-10 09:21:15 UTC
std::stringbuf::seekoff return wrong position value.
solution: patch:

--- include/bits/sstream.tcc.orig	2004-08-10 17:11:28.000000000 +0800
+++ include/bits/sstream.tcc	2004-08-10 17:11:59.000000000 +0800
@@ -160,14 +160,14 @@
 	      && this->egptr() - __beg >= __newoffi + __off)
 	    {
 	      this->gbump((__beg + __newoffi + __off) - this->gptr());
-	      __ret = pos_type(__newoffi);
+	      __ret = pos_type(__newoffi + __off);
 	    }
 	  if ((__testout || __testboth)
 	      && __newoffo + __off >= 0
 	      && this->egptr() - __beg >= __newoffo + __off)
 	    {
 	      this->pbump((__beg + __newoffo + __off) - this->pptr());
-	      __ret = pos_type(__newoffo);
+	      __ret = pos_type(__newoffo + __off);
 	    }
 	}
       return __ret;
Comment 1 Giovanni Bajo 2004-08-10 09:34:49 UTC
*** Bug 16957 has been marked as a duplicate of this bug. ***
Comment 2 Giovanni Bajo 2004-08-10 09:35:07 UTC
*** Bug 16958 has been marked as a duplicate of this bug. ***
Comment 3 GCC Commits 2004-08-12 22:26:39 UTC
Subject: Bug 16956

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	paolo@gcc.gnu.org	2004-08-12 22:26:33

Modified files:
	libstdc++-v3   : ChangeLog 
	libstdc++-v3/include/bits: sstream.tcc 
	libstdc++-v3/testsuite/27_io/basic_stringbuf/seekoff/char: 1.cc 
	libstdc++-v3/testsuite/27_io/basic_stringbuf/seekoff/wchar_t: 
	                                                              1.cc 
	libstdc++-v3/testsuite/27_io/basic_stringbuf/seekpos/char: 1.cc 
	libstdc++-v3/testsuite/27_io/basic_stringbuf/seekpos/wchar_t: 
	                                                              1.cc 
Added files:
	libstdc++-v3/testsuite/27_io/basic_stringbuf/seekoff/char: 
	                                                           16956.cc 
	libstdc++-v3/testsuite/27_io/basic_stringbuf/seekoff/wchar_t: 
	                                                              16956.cc 

Log message:
	2004-08-12  Paolo Carlini  <pcarlini@suse.de>
	
	PR libstdc++/16956
	* include/bits/sstream.tcc (basic_stringbuf<>::seekoff): Add __off
	to the returned value, reorganize a bit.
	* testsuite/27_io/basic_stringbuf/seekoff/char/16956.cc: New.
	* testsuite/27_io/basic_stringbuf/seekoff/wchar_t/16956.cc: New.
	
	* testsuite/27_io/basic_stringbuf/seekoff/char/1.cc: Remove junk.
	* testsuite/27_io/basic_stringbuf/seekoff/wchar_t/1.cc: Likewise.
	* testsuite/27_io/basic_stringbuf/seekpos/char/1.cc: Likewise.
	* testsuite/27_io/basic_stringbuf/seekpos/wchar_t/1.cc: Likewise.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/ChangeLog.diff?cvsroot=gcc&r1=1.2609&r2=1.2610
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/include/bits/sstream.tcc.diff?cvsroot=gcc&r1=1.40&r2=1.41
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/testsuite/27_io/basic_stringbuf/seekoff/char/16956.cc.diff?cvsroot=gcc&r1=NONE&r2=1.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/testsuite/27_io/basic_stringbuf/seekoff/char/1.cc.diff?cvsroot=gcc&r1=1.3&r2=1.4
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/testsuite/27_io/basic_stringbuf/seekoff/wchar_t/16956.cc.diff?cvsroot=gcc&r1=NONE&r2=1.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/testsuite/27_io/basic_stringbuf/seekoff/wchar_t/1.cc.diff?cvsroot=gcc&r1=1.1&r2=1.2
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/testsuite/27_io/basic_stringbuf/seekpos/char/1.cc.diff?cvsroot=gcc&r1=1.3&r2=1.4
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/testsuite/27_io/basic_stringbuf/seekpos/wchar_t/1.cc.diff?cvsroot=gcc&r1=1.1&r2=1.2

Comment 4 Paolo Carlini 2004-09-23 11:01:49 UTC
Fixed for 4.0. The deep behavior change is not suited for a dot-release.