This is the mail archive of the gcc-bugs@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++/8637: istream& get (char* s, streamsize n, char delim ) does not work


>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:


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