libstdc++/4627: std::ofstream::open(ios::ate) does not seek to EOF

tmwg-gcc@inxservices.com tmwg-gcc@inxservices.com
Fri Oct 19 21:46:00 GMT 2001


>Number:         4627
>Category:       libstdc++
>Synopsis:       ios::ate open does not seek to EOF, it truncates
>Confidential:   no
>Severity:       critical
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          wrong-code
>Submitter-Id:   net
>Arrival-Date:   Fri Oct 19 21:46:03 PDT 2001
>Closed-Date:
>Last-Modified:
>Originator:     George Garvey
>Release:        3.0.2 20011007 (prerelease)
>Organization:
<inX Services>
>Environment:
System: Linux mwg 2.4.12-ac3 #1 Wed Oct 17 08:47:44 PDT 2001 i686 unknown
Architecture: i686

	
host: i686-pc-linux-gnu
build: i686-pc-linux-gnu
target: i686-pc-linux-gnu
configured with: ../configure --prefix=/usr --exec-prefix=/usr --datadir=/usr/lib --includedir=/usr/local/include --with-gnu-ld --with-gnu-as --with-local-prefix=/usr/local/include --with-gxx-include-dir=/usr/include/c++3 --with-cpp-install-dir=/lib --disable-c-mbchar --enable-threads=posix --with-dwarfx --enable-shared --disable-nls --with-system-zlib --enable-version-specific-runtime-libs --with-slibdir=/lib --enable-fast-character --enable-interpreter --with-x --enable-clocale=gnu --disable-c-mbchar --enable-long-long --enable-cheaders=c_std --enable-languages=c,c++,gcov,proto --verbose --host=i686-pc-linux-gnu --build=i686-pc-linux-gnu --target=i686-pc-linux-gnu
>Description:
Compile the code below with g++ -otst tst.cc
./tst results in the following output:
2testing
I expected:
1testing
2testing
>How-To-Repeat:
#include <iostream>
#include <fstream>

	using namespace std;

int
main(const int args, char *const *arg) {
	ofstream *efile(new ofstream);
	efile->open("test.out", ios::out | ios::ate);
	*efile << "1testing\n";
	efile->close();
	delete efile;

	efile = new ofstream;
	efile->open("test.out", ios::out | ios::ate);
	*efile << "2testing\n";
	efile->close();
	delete efile;

	return 0;
}
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted:



More information about the Gcc-bugs mailing list