This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
libstdc++/8637: istream& get (char* s, streamsize n, char delim ) does not work
- From: castaway at desert-island dot m dot isar dot de
- To: gcc-gnats at gcc dot gnu dot org
- Date: 19 Nov 2002 14:14:02 -0000
- Subject: libstdc++/8637: istream& get (char* s, streamsize n, char delim ) does not work
- Reply-to: castaway at desert-island dot m dot isar dot de
>Number: 8637
>Category: libstdc++
>Synopsis: istream& get (char* s, streamsize n, char delim ) does not work
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Tue Nov 19 06:16:08 PST 2002
>Closed-Date:
>Last-Modified:
>Originator: castaway@desert-island.m.isar.de
>Release: gcc30-3.0.4-25 (SuSE 8.0) and g++ (GCC) 3.2.1 20021108
>Organization:
>Environment:
SuSE 8.0 / i686-pc-linux-gnu
>Description:
3.0.4 was a standard SuSE 8.0
3.2.1 : --host=i686-pc-linux-gnu --enable-shared --enable-languages=c,c++ --enable-threads=posix --enable-__cxa_atexit --enable- --enable-clocale=gnu
istream& get (char* s, streamsize n, char delim ) should read text until the next delimiter given, _and leave the delimiter on the stream_ (worked in 2.95.3)
>How-To-Repeat:
Example:
1. Create a file with contents "" (double quotes) and nothing else) - programm produces a seg-fault, when run through gdb it produces incorrect output (both delimiters should be ")
2. Create a file with contents "test" - this produces correct output in gcc 3.0.4 but not in 3.2.1.
- Both examples work in 2.95.3
// istream get
#include <iostream>
#include <fstream>
using namespace std;
int main () {
char * c, str[256];
ifstream is;
char delim;
cout << "Enter the name of an existing text file: ";
cin.get (str,256);
is.open (str); // open file
delim = is.get();
cout << "Delimiter: " << delim << endl;
is.get(c, 50, '"'); // get character from file
cout << c << endl;
if(is.fail())
{
cout << "Failed" << endl;
}
delim = is.get();
cout << "Delimiter: " << delim << endl;
is.close(); // close file
return 0;
}
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted: