Strange File I/O Problem

Hello everybody,

I I have a strange problem.

I simply try to read out a file in the following way:

#include <iostream>

#include <fstream>

#include <cuda.h>

using namespace std;

int main() {

        ifstream ifs;

        ifs.open("sequence.fl",ifstream::in);

string line;

        while(!ifs.eof()) {

                getline(ifs,line);

                cout << line << endl;

        }   

        ifs.close();

        return 0;

}

When I compile the code with nvcc (release 4.0, V0.2.1221) then the while loop never converges. This means the eof() always returns false.

If I compile the code with g++ or gcc (4.2), everything works fine.

I use OS-X Snow Leopard.

Does someone know what the problem could be? That is a really annoying problem because I try to parallelize some computations in a big project. Everything works fine until now. Only try to figure out this strange behavior.

Thanks a lot,

Dominik

I can confirm this bug - and it is most annoying and in need of a fix

nvcc 4.0 v0.2.1221

g++ 4.2.1

Mac OS x 10.6.8

a simple catch to terminate the loop by counting empty lines is

int emptyline = 0;

        while(!ifs.eof() && emptyline <100) {

                getline(ifs,line);

                if (line.length()>0) {

                    cout << line << endl;

                    emptyline=0;

                } else {

                    emptyline++;

                } 

        }