[Boost-bugs] [Boost C++ Libraries] #4054: is_open() of streams returns true even if the device failed to open

Subject: [Boost-bugs] [Boost C++ Libraries] #4054: is_open() of streams returns true even if the device failed to open
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2010-03-30 13:06:25


#4054: is_open() of streams returns true even if the device failed to open
-------------------------------------------+--------------------------------
 Reporter: Daniel Eiband <eiband@…> | Owner: turkanis
     Type: Bugs | Status: new
Milestone: Boost 1.43.0 | Component: iostreams
  Version: Boost 1.42.0 | Severity: Problem
 Keywords: |
-------------------------------------------+--------------------------------
 boost::iostreams::stream<Device>::is_open() always returns true after a
 call to open() even if the underlying device failed to open the stream.

 As far as I looked into the code the indirect_streambuf stores an open-
 flag which is tested for in the is_open() implementation. is_open() of the
 device never gets called.

 Code snippet to reproduce the problem (make sure that the file "test" does
 not exist):


 {{{
 std::string filename("test");
 boost::iostreams::stream<boost::iostreams::file_source> file;

 file.open(filename.c_str());
 if (file.is_open())
 {
   // assert fires if file "test" does not exist
   assert(boost::filesystem::exists(filename));
 }
 }}}


 With the std::ifstream shipped with MSVC 9.0 the assert never fires.

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/4054>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:02 UTC