This is the mail archive of the gcc-prs@gcc.gnu.org mailing list for the GCC 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]

libstdc++/9507: filebuf::open handles ios_base::ate incorrectly


>Number:         9507
>Category:       libstdc++
>Synopsis:       filebuf::open handles ios_base::ate incorrectly
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Jan 30 14:46:01 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator:     peturr02@ru.is
>Release:        gcc-3.2.1
>Organization:
>Environment:
Red Hat Linux 8.0
>Description:
When the flag ios_base::ate is passed to basic_filebuf::open, the filebuf tries to seek to the end of the file (as expected). If this seek fails, the file is closed before open returns (also as expected). However, the return value still indicates that open was successful, even though is_open is false after the call to open.
>How-To-Repeat:
See attachment.
>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: text/plain; name="openseekbug.cc"
Content-Disposition: inline; filename="openseekbug.cc"

#include <fstream>
#include <unistd.h>
#include <signal.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>

#undef NDEBUG
#include <cassert>

int main()
{
	using namespace std;

	signal(SIGPIPE, SIG_IGN);

	unlink("xxx");
	mkfifo("xxx", S_IRWXU);

	if (!fork())
	{
		filebuf fbuf;
		fbuf.open("xxx", ios_base::in);
		fbuf.sgetc();
		fbuf.close();

		exit(0);
	}

	filebuf fbuf;
	filebuf* r = fbuf.open("xxx", ios_base::out | ios_base::ate);
	assert(!fbuf.is_open());
	assert(r == NULL);

	unlink("xxx");
	return 0;
}


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