osdir.com
mailing list archive F.A.Q. -since 2001!



Subject: libstdc++/7424: libstdc++: ifstream::open() does
not work on used ifstream objects - msg#00737

List: gcc.prs

Mail Archive Navigation:
by Date: Prev Next Date Index by Thread: Prev Next Thread Index


>Number: 7424
>Category: libstdc++
>Synopsis: libstdc++: ifstream::open() does not work on used ifstream
>objects
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Sun Jul 28 06:46:00 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator: Roger Leigh
>Release: 3.1.1 20020703 (Debian prerelease) (Debian testing/unstable)
>Organization:
N/A
>Environment:
System: Linux whinlatter 2.4.18 #6 Thu Jul 11 11:41:55 BST 2002 i686 unknown
Architecture: i686


host: i386-pc-linux-gnu
build: i386-pc-linux-gnu
target: i386-pc-linux-gnu
configured with: /mnt/data/gcc-3.1/gcc-3.1-3.1.1ds2/src/configure -v
--enable-languages=c,c++,java,f77,proto,objc,ada --prefix=/usr
--mandir=/usr/share/man --infodir=/usr/share/info
--with-gxx-include-dir=/usr/include/g++-v3-3.1 --enable-shared
--with-system-zlib --enable-long-long --enable-nls --without-included-gettext
--enable-clocale=gnu --enable-__cxa_atexit --enable-threads=posix
--enable-java-gc=boehm --enable-objc-gc i386-linux
>Description:
The following code works with g++-2.95, but not g++-3.0 or g++-3.1
(example). For the latter two, re-using the same ifstream object
(ifstream::open()) results in failure. Defining and using a new
ifstream object is OK.

Test output (g++-3.1):
roger@whinlatter:~/cc/16$ ./test2
Open(1) succeeded
Current file contents:
[file contents]

***EOF***
Unable to open filename for appending.

Test output (6++-2.95):
roger@whinlatter:~/cc/16$ ./test2
Open(1) succeeded
Current file contents:
[file contents]

***EOF***
Open(2) succeeded

Note the second open fails for g++ 3.1.

I'm willing to provide any additional data you might require. My
system is Debian GNU/Linux (sid). As my incoming email is broken
right now (at the ISP), I might not be reachable. My phone number
is +44 01254 664642 (UK).
>How-To-Repeat:
If lines 16-23 are commented out, it will run successfully (gcc 3.0
and 3.1) otherwise both will fail to reopen the file (but gcc 2.95.2
will succeed).

#include <fstream>
#include <iostream>
using std::cout;
using std::ifstream;

int main()
{
char* filename = "filename";
ifstream infile(filename);
if (!infile)
{
cout << "Unable to open " << filename << " for reading.\n";
return 1;
}
cout << "Open(1) succeeded\n";
if (infile)
{
cout << "Current file contents:\n";
char ch;
while (infile.get(ch))
cout << ch;
cout << "\n***EOF***\n";
}
infile.close();

infile.open(filename);
if (!infile)
{
cout << "Unable to open " << filename << " for appending.\n";
return 1;
}
cout << "Open(2) succeeded\n";
// read file again
infile.close();

return 0;
}
>Fix:
None, sorry. I'm only just learning C++, and found this error when I
was
learning about iostream and file I/O.
>Release-Note:
>Audit-Trail:
>Unformatted:



Thread at a glance:

Previous Message by Date:

Re: c++/4862: [parser]Parse error with templated member function

Old Synopsis: Parse error with templated member function New Synopsis: [parser]Parse error with templated member function State-Changed-From-To: analyzed->suspended State-Changed-By: lerdsuwa State-Changed-When: Sun Jul 28 05:18:30 2002 State-Changed-Why: Will be fixed in the new parser. http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=4862

Next Message by Date:

Re: libstdc++/7424: libstdc++: ifstream::open() does not work on used ifstream objects

Synopsis: libstdc++: ifstream::open() does not work on used ifstream objects Responsible-Changed-From-To: unassigned->paolo Responsible-Changed-By: paolo Responsible-Changed-When: Sun Jul 28 07:09:16 2002 Responsible-Changed-Why: Triaged. State-Changed-From-To: open->closed State-Changed-By: paolo State-Changed-When: Sun Jul 28 07:09:16 2002 State-Changed-Why: Not a bug. Please see the FAQ, entry 4.4 on reopening http://gcc.gnu.org/onlinedocs/libstdc++/faq/index.html#4_0 Thanks, Paolo. http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=7424

Previous Message by Thread:

Re: c++/4862: [parser]Parse error with templated member function

Old Synopsis: Parse error with templated member function New Synopsis: [parser]Parse error with templated member function State-Changed-From-To: analyzed->suspended State-Changed-By: lerdsuwa State-Changed-When: Sun Jul 28 05:18:30 2002 State-Changed-Why: Will be fixed in the new parser. http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=4862

Next Message by Thread:

Re: libstdc++/7424: libstdc++: ifstream::open() does not work on used ifstream objects

Synopsis: libstdc++: ifstream::open() does not work on used ifstream objects Responsible-Changed-From-To: unassigned->paolo Responsible-Changed-By: paolo Responsible-Changed-When: Sun Jul 28 07:09:16 2002 Responsible-Changed-Why: Triaged. State-Changed-From-To: open->closed State-Changed-By: paolo State-Changed-When: Sun Jul 28 07:09:16 2002 State-Changed-Why: Not a bug. Please see the FAQ, entry 4.4 on reopening http://gcc.gnu.org/onlinedocs/libstdc++/faq/index.html#4_0 Thanks, Paolo. http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=7424
blog comments powered by Disqus

Home | News | Sitemap | FAQ | advertise | OSDir is an Inevitable website. GBiz is too!