[PATCH] libstdc++/6648

Paolo Carlini pcarlini@unitus.it
Mon May 13 16:07:00 GMT 2002


Paolo Carlini wrote:

> On second thought, I'm not quite happy with the testcase.


Well, sorry, but even the second try it's not really ok, since the 
second input (that corresponding to istream::ignore) does not expose the 
bug if carried out after the istream::getline one. Therefore I'd rather 
prefer the following.

Sorry again for the confusion (I'm a bit tired)
Paolo.

//////////////

diff -urN libstdc++-v3-orig/include/bits/istream.tcc 
libstdc++-v3/include/bits/istream.tcc
--- libstdc++-v3-orig/include/bits/istream.tcc    2002-04-22 
21:10:01.000000000 +0200
+++ libstdc++-v3/include/bits/istream.tcc    2002-05-13 
22:32:43.000000000 +0200
@@ -679,7 +679,7 @@
         {
           if (__c == __idelim)
             {
-              __sb->snextc();
+              __sb->sbumpc();
               ++_M_gcount;
             }
           else
@@ -726,7 +726,7 @@
         this->setstate(ios_base::eofbit);
           else if (__c == __delim)
         {
-          __sb->snextc();
+          __sb->sbumpc();
           ++_M_gcount;
         }
         }
diff -urN libstdc++-v3-orig/testsuite/27_io/narrow_stream_objects.cc 
libstdc++-v3/testsuite/27_io/narrow_stream_objects.cc
--- libstdc++-v3-orig/testsuite/27_io/narrow_stream_objects.cc    
2002-05-03 20:22:58.000000000 +0200
+++ libstdc++-v3/testsuite/27_io/narrow_stream_objects.cc    2002-05-14 
00:47:49.000000000 +0200
@@ -175,6 +175,24 @@
   VERIFY( s == "test" );
 }
 
+// libstdc++/6648
+// Interactive tests: each one (run alone) must terminate upon a single 
'\n'.
+void test08()
+{
+  bool test = true;
+  char buff[2048];
+  std::cout << "Enter name: ";
+  std::cin.getline(buff, 2048);
+}
+
+void test09()
+{
+  bool test = true;
+  char buff[2048];
+  std::cout << "Enter another name: ";
+  std::cin.ignore(2048, '\n');
+}
+
 int
 main()
 {
@@ -186,5 +204,7 @@
   // test05();
   // test06();
   // test07();
+  // test08();
+  // test09();
   return 0;
 }




More information about the Libstdc++ mailing list