This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
[Patch] Fix libstdc++/9507 (take2)
- From: Paolo Carlini <pcarlini at unitus dot it>
- To: "libstdc++ at gcc dot gnu dot org" <libstdc++ at gcc dot gnu dot org>
- Cc: bkoz <bkoz at redhat dot com>
- Date: Sun, 02 Feb 2003 14:30:39 +0100
- Subject: [Patch] Fix libstdc++/9507 (take2)
Hi,
in fact, the testcase can be added as-is to filebuf_members.cc...
Unrelated, Pétur noticed a spurious exit(0) at the end of test_04.
Ok trunk and 3.3?
Paolo.
///////////
2003-02-02 Paolo Carlini <pcarlini@unitus.it>
PR libstdc++/9507
* include/bits/fstream.tcc (open): If the 'ate' repositioning
operation fails, calls close _and_ returns a null pointer
to indicate failure (27.8.1.3,4).
* testsuite/27_io/filebuf_members.cc (test_06): Add.
2003-02-02 Petur Runolfsson <peturr02@ru.is>
* testsuite/27_io/filebuf_members.cc (test_04): Remove exit(0).
diff -urN libstdc++-v3-orig/include/bits/fstream.tcc libstdc++-v3/include/bits/fstream.tcc
--- libstdc++-v3-orig/include/bits/fstream.tcc 2003-01-23 23:53:35.000000000 +0100
+++ libstdc++-v3/include/bits/fstream.tcc 2003-02-02 00:44:42.000000000 +0100
@@ -103,7 +103,11 @@
if ((__mode & ios_base::ate)
&& this->seekoff(0, ios_base::end, __mode) < 0)
- this->close();
+ {
+ // 27.8.1.3,4
+ this->close();
+ return __ret;
+ }
__ret = this;
}
diff -urN libstdc++-v3-orig/testsuite/27_io/filebuf_members.cc libstdc++-v3/testsuite/27_io/filebuf_members.cc
--- libstdc++-v3-orig/testsuite/27_io/filebuf_members.cc 2002-04-30 21:04:43.000000000 +0200
+++ libstdc++-v3/testsuite/27_io/filebuf_members.cc 2003-02-02 14:21:52.000000000 +0100
@@ -172,7 +172,6 @@
}
unlink("xxx");
- exit(0);
}
// Charles Leggett <CGLeggett@lbl.gov>
@@ -191,6 +190,33 @@
scratch_file.close();
}
+// libstdc++/9507
+void test_06()
+{
+ bool test = true;
+
+ signal(SIGPIPE, SIG_IGN);
+
+ unlink("yyy");
+ mkfifo("yyy", S_IRWXU);
+
+ if (!fork())
+ {
+ std::filebuf fbuf;
+ fbuf.open("yyy", std::ios_base::in);
+ fbuf.sgetc();
+ fbuf.close();
+
+ exit(0);
+ }
+
+ std::filebuf fbuf;
+ std::filebuf* r =
+ fbuf.open("yyy", std::ios_base::out | std::ios_base::ate);
+ VERIFY( !fbuf.is_open() );
+ VERIFY( r == NULL );
+}
+
int
main()
{
@@ -199,6 +225,7 @@
test_03();
test_04();
test_05();
+ test_06();
return 0;
}