An ifstream question

C

Count Dracula

To open a file, a utility I have uses basically the following
std::ifstream input;
input.open(filename);
if (!input.is_open())
// write error message, throw exception

Now if "filename" is an existing directory instead of a file, then
when
compiled with g++ version 4.1.1, no error message is written and no
exception is thrown. If later an attempt is made to read something
from input, an exception is thrown.

When compiled with a recent version of VC++, the same code writes
an error message and throws an exception if "filename" happens to be
a directory instead of a regular file.

Is this a bug in g++? Or is it not enough to use is_open() as shown
when using g++?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

ifstream errors 15
ifstream 5
ifstream question 26
ifstream performance. 2
About ifstream 2
Error with ifstream and exceptions 71
ifstream problem? 13
multi-thread and ifstream 1

Members online

No members online now.

Forum statistics

Threads
473,778
Messages
2,569,605
Members
45,238
Latest member
Top CryptoPodcasts

Latest Threads

Top