Opened 14 years ago
Closed 13 years ago
#2817 closed Bugs (fixed)
boost::iostreams::file_descriptor::is_open() implemented incorrectly
Reported by: | Owned by: | Jonathan Turkanis | |
---|---|---|---|
Milestone: | Boost 1.39.0 | Component: | iostreams |
Version: | Boost 1.38.0 | Severity: | Problem |
Keywords: | file_descriptor is_open | Cc: |
Description
On line 70 of file_descriptor.hpp the is_open() function checks if flags are zero to determine if the file descriptor is open:
bool is_open() const { return pimpl_->flags_ != 0; }
pimpl_->flags_ is always zero unless close_on_exit is enabled. So close_on_exit is the only thing that determines what is_open() will return. I believe the code should be:
#ifdef BOOST_IOSTREAMS_WINDOWS
bool is_open() const { return pimpl_->handle_ != reinterpret_cast<handle_type>(1); }
#else
bool is_open() const { return pimpl_->handle_ != -1; }
#endif
Thanks!
Change History (4)
comment:1 by , 14 years ago
comment:2 by , 13 years ago
I concur it's implemented incorrectly.
However, some functions on Windows return 0 instead of INVALID_HANDLE_VALUE, so I think it should be compared against both.
comment:3 by , 13 years ago
further (independent) discussion of this issue occurred on the devel list recently. see: http://thread.gmane.org/gmane.comp.lib.boost.devel/190541
comment:4 by , 13 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Looks like this was fixed in [46669].
Oops, my previous code is missing a '-'. The code should read as follows:
#ifdef BOOST_IOSTREAMS_WINDOWS
#else
#endif