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

Problem with fstream in gcc3.4.0 (directory reading allowed?)


Hello,

I have problem with MICO's mkdepend utility which shows wrong behaviour
compiled with gcc 3.4.0 20040415. I have simplified mkdepend code to this
testcase:

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

using namespace std;

int
main()
{
        char rawline[10000];
        string f = "/usr/include";
        ifstream inp (f.c_str());
        if (!inp) {
            cerr << f << ": cannot open" << endl;
            return 0;
        }
        while (!inp.getline (rawline, sizeof(rawline)).eof()) {
            string line = rawline;
	    cerr << f << ": line: " << line << endl;
        }
        return 0;
}


What we expect is that it is not possible to read from /usr/include
directory by using fstream and so while block will not be executed. At
least that's behaviour obtained from various C++ compilers during several
past years and also I have tested it now with gcc3.3.2, como4.3.3 and
icc8.0. The problem is that if this code is compiled with gcc3.4.0, it
executes while loop which become infinite loop and prints:

thinkpad:/tmp$ ./dirbug34
/usr/include: line:
/usr/include: line:
/usr/include: line:
/usr/include: line:
/usr/include: line:
/usr/include: line:
/usr/include: line:
/usr/include: line:
/usr/include: line:
/usr/include: line:
/usr/include: line:
/usr/include: line:
/usr/include: line:
/usr/include: line:
....


My question is: is this known problem with gcc3.4.0 or is our assumption
about reading directory by using fstream wrong?

Thanks a lot,

Karel

PS: OS used is Debian GNU/Linux 3.0 + kernel 2.6.4 + binutils 2.14 +
    selected compiler
--
Karel Gardas                  kgardas@objectsecurity.com
ObjectSecurity Ltd.           http://www.objectsecurity.com


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