Boost C++ Libraries: Ticket #2817: boost::iostreams::file_descriptor::is_open() implemented incorrectly https://svn.boost.org/trac10/ticket/2817 <p> On line 70 of file_descriptor.hpp the is_open() function checks if flags are zero to determine if the file descriptor is open: </p> <blockquote> <p> bool is_open() const { return pimpl_-&gt;flags_ != 0; } </p> </blockquote> <p> pimpl_-&gt;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: </p> <p> #ifdef BOOST_IOSTREAMS_WINDOWS </p> <blockquote> <p> bool is_open() const { return pimpl_-&gt;handle_ != reinterpret_cast&lt;handle_type&gt;(1); } </p> </blockquote> <p> #else </p> <blockquote> <p> bool is_open() const { return pimpl_-&gt;handle_ != -1; } </p> </blockquote> <p> #endif </p> <p> Thanks! </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/2817 Trac 1.4.3 anonymous Mon, 02 Mar 2009 22:23:41 GMT <link>https://svn.boost.org/trac10/ticket/2817#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/2817#comment:1</guid> <description> <p> Oops, my previous code is missing a '-'. The code should read as follows: </p> <p> #ifdef BOOST_IOSTREAMS_WINDOWS </p> <blockquote> <p> bool is_open() const { return pimpl_-&gt;handle_ != reinterpret_cast&lt;handle_type&gt;(-1); } </p> </blockquote> <p> #else </p> <blockquote> <p> bool is_open() const { return pimpl_-&gt;handle_ != -1; } </p> </blockquote> <p> #endif </p> </description> <category>Ticket</category> </item> <item> <dc:creator>anonymous</dc:creator> <pubDate>Thu, 11 Jun 2009 13:03:52 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/2817#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/2817#comment:2</guid> <description> <p> I concur it's implemented incorrectly. </p> <p> However, some functions on Windows return 0 instead of INVALID_HANDLE_VALUE, so I think it should be compared against both. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>anonymous</dc:creator> <pubDate>Sun, 14 Jun 2009 06:59:39 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/2817#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/2817#comment:3</guid> <description> <p> further (independent) discussion of this issue occurred on the devel list recently. see: <a class="ext-link" href="http://thread.gmane.org/gmane.comp.lib.boost.devel/190541"><span class="icon">​</span>http://thread.gmane.org/gmane.comp.lib.boost.devel/190541</a> </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Daniel James</dc:creator> <pubDate>Fri, 12 Mar 2010 20:04:14 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/2817#comment:4 https://svn.boost.org/trac10/ticket/2817#comment:4 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> </ul> <p> Looks like this was fixed in <a class="changeset" href="https://svn.boost.org/trac10/changeset/46669" title="updated to allow pathnames to be supplied as Boost.Filesystem paths ...">[46669]</a>. </p> Ticket