Blame SOURCES/gcc48-pr81395.patch

22033d
2017-07-18  Jonathan Wakely  <jwakely@redhat.com>
22033d
22033d
	PR libstdc++/81395
22033d
	* include/bits/fstream.tcc (basic_filebuf::xsgetn): Don't set buffer
22033d
	pointers for write mode after reading.
22033d
	* testsuite/27_io/basic_filebuf/sgetn/char/81395.cc: New.
22033d
22033d
--- libstdc++-v3/include/bits/fstream.tcc	(revision 254017)
22033d
+++ libstdc++-v3/include/bits/fstream.tcc	(revision 254018)
22033d
@@ -699,7 +699,7 @@
22033d
  
22033d
  	   if (__n == 0)
22033d
  	     {
22033d
- 	       _M_set_buffer(0);
22033d
+	       // Set _M_reading. Buffer is already in initial 'read' mode.
22033d
  	       _M_reading = true;
22033d
  	     }
22033d
  	   else if (__len == 0)
22033d
--- libstdc++-v3/testsuite/27_io/basic_filebuf/sgetn/char/81395.cc	(nonexistent)
22033d
+++ libstdc++-v3/testsuite/27_io/basic_filebuf/sgetn/char/81395.cc	(revision 254018)
22033d
@@ -0,0 +1,46 @@
22033d
+// Copyright (C) 2017 Free Software Foundation, Inc.
22033d
+//
22033d
+// This file is part of the GNU ISO C++ Library.  This library is free
22033d
+// software; you can redistribute it and/or modify it under the
22033d
+// terms of the GNU General Public License as published by the
22033d
+// Free Software Foundation; either version 3, or (at your option)
22033d
+// any later version.
22033d
+
22033d
+// This library is distributed in the hope that it will be useful,
22033d
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
22033d
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22033d
+// GNU General Public License for more details.
22033d
+
22033d
+// You should have received a copy of the GNU General Public License along
22033d
+// with this library; see the file COPYING3.  If not see
22033d
+// <http://www.gnu.org/licenses/>.
22033d
+
22033d
+// { dg-require-fileio "" }
22033d
+
22033d
+// PR libstdc++/81395
22033d
+
22033d
+#include <fstream>
22033d
+#include <cstring>	// for std::memset
22033d
+#include <cstdio>	// For BUFSIZ
22033d
+
22033d
+using std::memset;
22033d
+
22033d
+int main()
22033d
+{
22033d
+  {
22033d
+    std::filebuf fb;
22033d
+    fb.open("test.txt", std::ios::out);
22033d
+    char data[BUFSIZ];
22033d
+    memset(data, 'A', sizeof(data));
22033d
+    fb.sputn(data, sizeof(data));
22033d
+  }
22033d
+
22033d
+  std::filebuf fb;
22033d
+  fb.open("test.txt", std::ios::in|std::ios::out);
22033d
+  char buf[BUFSIZ];
22033d
+  memset(buf, 0, sizeof(buf));
22033d
+  fb.sgetn(buf, sizeof(buf));
22033d
+  // Switch from reading to writing without seeking first:
22033d
+  fb.sputn("B", 1);
22033d
+  fb.pubsync();
22033d
+}