Boost C++ Libraries: Ticket #3935: stream<file_sink> does not throw an exception and not set fail/bad bits when file is wrong https://svn.boost.org/trac10/ticket/3935 <p> I'm trying to write some content to a new file using boost::stream&lt;file_sink&gt; class. Unfortunately errors/failures during opening the file are ignored by boost library. </p> <p> See attached test.cpp file for snippet. </p> <p> Above program is started as non root user and have not access for file /wrong.txt </p> <p> Result is:<br /> mariusz@ppbw:~/boost-1.42$ ./test <br /> boost ver:1_42 <br /> 0 0<br /> nothing thrown<br /> </p> <p> mariusz@ppbw:~/boost-1.42$ ls /<br /> bin dev initrd.img lost+found opt sbin tmp vmlinuz<br /> boot etc initrd.img.old media proc srv usr vmlinuz.old<br /> cdrom home lib mnt root sys var<br /> </p> <p> mariusz@ppbw:~/boost-1.42$ ldd ./test<br /> </p> <blockquote> <p> linux-gate.so.1 =&gt; (0xb7fc4000)<br /> libstdc++.so.6 =&gt; /usr/lib/libstdc++.so.6 (0xb7eb0000)<br /> libm.so.6 =&gt; /lib/tls/i686/cmov/libm.so.6 (0xb7e8a000)<br /> libgcc_s.so.1 =&gt; /lib/libgcc_s.so.1 (0xb7e6c000)<br /> libc.so.6 =&gt; /lib/tls/i686/cmov/libc.so.6 (0xb7d0e000)<br /> /lib/ld-linux.so.2 (0xb7faa000)<br /> </p> </blockquote> <p> mariusz@ppbw:~/boost-1.42$ <br /> </p> <p> Similar program using std::ofstream works as I expected: </p> <ul><li>console prints: 1 0<br /> </li><li>exception is thrown <br /> </li></ul><p> I made tests using:<br /> boost 1.42<br /> Ubuntu 8.10 intrepid<br /> g++ (Debian 4.3.2-1.1) 4.3.2<br /> </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/3935 Trac 1.4.3 zxspeccy.cpp@… Tue, 16 Feb 2010 13:29:27 GMT attachment set https://svn.boost.org/trac10/ticket/3935 https://svn.boost.org/trac10/ticket/3935 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">test.cpp</span> </li> </ul> <p> Program, which should throw an exception, but instead it just ignore failures </p> Ticket anonymous Wed, 05 Nov 2014 04:30:42 GMT <link>https://svn.boost.org/trac10/ticket/3935#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/3935#comment:1</guid> <description> <p> Five years and this serious bug is still open? </p> <p> As a workaround, use file_descriptor_sink. That one throws an exception if the file can't be opened. </p> </description> <category>Ticket</category> </item> </channel> </rss>