This is the mail archive of the
gcc-prs@gcc.gnu.org
mailing list for the GCC project.
Re: libstdc++/5297: operator!() const incorrect for fstream class
- From: Uwe Seimet <us at orbacus dot com>
- To: nobody at gcc dot gnu dot org
- Cc: gcc-prs at gcc dot gnu dot org,
- Date: 7 Jan 2002 14:36:01 -0000
- Subject: Re: libstdc++/5297: operator!() const incorrect for fstream class
- Reply-to: Uwe Seimet <us at orbacus dot com>
The following reply was made to PR libstdc++/5297; it has been noted by GNATS.
From: Uwe Seimet <us@orbacus.com>
To: Carlo Wood <carlo@alinoe.com>
Cc: gcc-gnats@gcc.gnu.org
Subject: Re: libstdc++/5297: operator!() const incorrect for fstream class
Date: Mon, 7 Jan 2002 15:29:39 +0100
Hello Carlo,
> > fstream afile(MYNAME, ios::in|ios::out|ios::app);
> > assert(afile);
>
> Did you mean: assert(!afile); ?
Actually our code looks like this:
fstream afile(m_asset_file, ios::in|ios::out|ios::app);
if (!afile) {
cerr << "Cannot open " << m_asset_file << endl;
throw 0;
}
Even if the stream could be created I get the "Cannot open" message with gcc
3.0.3. With other C++ compiler and also with gcc 2.95.3 everything is fine.
!afile should evaluate to false, not to true, because operator!() const
should return the result of fail(), as mandated by ISO C++, 27.4.4.3.
Best regards, Uwe
--
----------------------------------------------------------------------------
Dr. Uwe Seimet mailto:us@orbacus.com
IONA - END 2 ANYWHERE http://www.orbacus.com