This is the mail archive of the 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]

c++/3750: stream input operator>> fails in g++ 3.0

>Number:         3750
>Category:       c++
>Synopsis:       stream input operator>> fails in g++ 3.0
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Jul 20 09:46:01 PDT 2001
>Originator:     Jeff Dahl
SunOS 5.6 Generic_105181-25 sun4m sparc SUNW,SPARCstation-20
public class HelloWorld
    public static void main(String [] args) 

#include <iostream>
#include <string>
#include <fstream>

using std::string;
using std::cerr;
using std::cout;
using std::endl;
using std::ifstream;
using std::ios;

int main( int argc, char *argv[] )
  string fileArg;

  ifstream inFile( "/u/jddahl/", ios::in );

  if( !inFile )
      cerr << "File could not be opened" << endl;
  while( !inFile.eof( ))
      //getline( inFile, fileArg );
      inFile >> fileArg;
      cout << "[" << fileArg << "]" << endl;
  return 0;

OUTPUT WITH g++ -V 3.0:
{jddahl}67> g++ -V 3.0 test.cpp
{jddahl}68> a.out
[public class Hello]
    public static void main(]
[tring ]
[] args) 

OUTPUT WITH g++ -V 2.95.3:
{jddahl}69> g++ -V 2.95.3 test.cpp
{jddahl}70> a.out

g++ -V 3.0 output is all messed up-- dropping letters, 
grabbing whitespace etc.
compile the source file with g++ -V 2.95.3 and g++ -V 3.0 and 
compare the output.
use getline and strtok each line
 gcc version 3.0

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