public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/14653] New: Semantics of ifstream.bad have changed from gcc 2.95.3 to gcc 3.2.3
@ 2004-03-19 15:44 saunak dot chakrabarti at gs dot com
2004-03-19 15:52 ` [Bug libstdc++/14653] " pinskia at gcc dot gnu dot org
2004-03-19 15:53 ` pinskia at gcc dot gnu dot org
0 siblings, 2 replies; 3+ messages in thread
From: saunak dot chakrabarti at gs dot com @ 2004-03-19 15:44 UTC (permalink / raw)
To: gcc-bugs
Linux egnoq01pb01.ny.eq.gs.com 2.4.18-19bigmem #1 SMP Thu Feb 27 14:21:17 EST
2003 i686
In the test program below, the ifstream is not 'bad' when the associated file
does not exist. In gcc 2.95.3, this was not the case. What was the reason for
changing the semantics of ifstream.bad()? Of note, ifstream.fail() detects
when a file does not exist in both cases.
#include <iostream.h>
#include <fstream.h>
int main()
{
ifstream routerIn( "/home/salesoma/router.config");
if ( routerIn.bad() )
{
cerr << "Problem!" << endl;
}
else
cerr << "No Problem " << endl;
return 0;
}
Gcc 2.95.3 says Problem!
But GCC 3.2.3 says NoProblem!
--
Summary: Semantics of ifstream.bad have changed from gcc 2.95.3
to gcc 3.2.3
Product: gcc
Version: 3.2.3
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: saunak dot chakrabarti at gs dot com
CC: gcc-bugs at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14653
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug libstdc++/14653] Semantics of ifstream.bad have changed from gcc 2.95.3 to gcc 3.2.3
2004-03-19 15:44 [Bug c++/14653] New: Semantics of ifstream.bad have changed from gcc 2.95.3 to gcc 3.2.3 saunak dot chakrabarti at gs dot com
@ 2004-03-19 15:52 ` pinskia at gcc dot gnu dot org
2004-03-19 15:53 ` pinskia at gcc dot gnu dot org
1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-03-19 15:52 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2004-03-19 15:52 -------
The bad function is not correct in this situtiation:
>From the C++ standard, 27.4.2.1.3:
badbit indicates a loss of integrity in an input or output sequence (such as an irrecoverable read error
from a file);
eofbit indicates that an input operation reached the end of an input sequence;
failbit indicates that an input operation failed to read the expected characters, or that an output
operation failed to generate the desired characters.
Looks like fail is what is needed here.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Component|c++ |libstdc++
Resolution| |INVALID
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14653
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug libstdc++/14653] Semantics of ifstream.bad have changed from gcc 2.95.3 to gcc 3.2.3
2004-03-19 15:44 [Bug c++/14653] New: Semantics of ifstream.bad have changed from gcc 2.95.3 to gcc 3.2.3 saunak dot chakrabarti at gs dot com
2004-03-19 15:52 ` [Bug libstdc++/14653] " pinskia at gcc dot gnu dot org
@ 2004-03-19 15:53 ` pinskia at gcc dot gnu dot org
1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-03-19 15:53 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2004-03-19 15:53 -------
oh by the way fail works you expected.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14653
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2004-03-19 15:53 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-03-19 15:44 [Bug c++/14653] New: Semantics of ifstream.bad have changed from gcc 2.95.3 to gcc 3.2.3 saunak dot chakrabarti at gs dot com
2004-03-19 15:52 ` [Bug libstdc++/14653] " pinskia at gcc dot gnu dot org
2004-03-19 15:53 ` pinskia at gcc dot gnu dot org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).