Boost C++ Libraries: Ticket #3335: boost::threads does not compile with gcc -fno-exceptions https://svn.boost.org/trac10/ticket/3335 <p> The following program fails to compile: </p> <p> --snip #define BOOST_NO_EXCEPTIONS </p> <p> #include &lt;boost/thread/mutex.hpp&gt; </p> <p> int foo; </p> <p> int fn(boost::mutex&amp; pMutex) { </p> <blockquote> <p> boost::mutex::scoped_lock lock(pMutex); return foo; </p> </blockquote> <p> } </p> <p> --snip </p> <p> It fails: </p> <p> # g++ -fno-exceptions -I/home/andyc/work/3rdParty/boost_1_39_0 -c -o test.o test.cpp In file included from /home/andyc/work/3rdParty/boost_1_39_0/boost/thread/mutex.hpp:16, </p> <blockquote> <p> from test.cpp:3: </p> </blockquote> <p> /home/andyc/work/3rdParty/boost_1_39_0/boost/thread/pthread/mutex.hpp: In constructor ?boost::mutex::mutex()?: /home/andyc/work/3rdParty/boost_1_39_0/boost/thread/pthread/mutex.hpp:40: error: exception handling disabled, use -fexceptions to enable </p> <p> There are other exceptions in boost/thread/locks.hpp that aren't surrounded by #ifndef BOOST_NO_EXCEPTIONS too. I've attached a patch to fix those. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/3335 Trac 1.4.3 Andrew Chittenden <andyc@…> Tue, 11 Aug 2009 14:24:34 GMT attachment set https://svn.boost.org/trac10/ticket/3335 https://svn.boost.org/trac10/ticket/3335 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">locks.hpp.patch</span> </li> </ul> <p> patch to boost/thread/locks.hpp to make it BOOST_NO_EXCEPTIONS aware. </p> Ticket Andrew Chittenden <andyc@…> Tue, 11 Aug 2009 15:34:06 GMT attachment set https://svn.boost.org/trac10/ticket/3335 https://svn.boost.org/trac10/ticket/3335 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">mutex.hpp.patch</span> </li> </ul> <p> patch to boost/thread/pthread/mutex.hpp to make it BOOST_NO_EXCEPTIONS aware. </p> Ticket Steven Watanabe Tue, 11 Aug 2009 18:58:02 GMT component changed; owner set https://svn.boost.org/trac10/ticket/3335#comment:1 https://svn.boost.org/trac10/ticket/3335#comment:1 <ul> <li><strong>owner</strong> set to <span class="trac-author">Anthony Williams</span> </li> <li><strong>component</strong> <span class="trac-field-old">None</span> → <span class="trac-field-new">thread</span> </li> </ul> Ticket Andrew Chittenden <andyc@…> Wed, 12 Aug 2009 09:27:01 GMT <link>https://svn.boost.org/trac10/ticket/3335#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/3335#comment:2</guid> <description> <p> using once.hpp also fails to compile: </p> <p> &lt;pre&gt; --snip #define BOOST_NO_EXCEPTIONS </p> <p> #include &lt;boost/thread/once.hpp&gt; </p> <p> boost::once_flag once = BOOST_ONCE_INIT; </p> <p> bool initialised = false; </p> <p> void testOnceInit() { </p> <blockquote> <p> assert(!initialised); initialised = true; </p> </blockquote> <p> } </p> <p> struct <a class="missing wiki">ConstructOnce</a> { </p> <blockquote> <p> <a class="missing wiki">ConstructOnce</a>() { </p> <blockquote> <p> boost::call_once(&amp;testOnceInit, once); </p> </blockquote> <p> } </p> </blockquote> <p> }; </p> <p> <a class="missing wiki">ConstructOnce</a> first; <a class="missing wiki">ConstructOnce</a> second; </p> <p> --snip # g++ -Wall -fno-exceptions -I/home/andyc/work/3rdParty/boost_1_39_0 -c -o testonce.o testonce.cpp /home/andyc/work/3rdParty/boost_1_39_0/boost/thread/pthread/once.hpp: In function ?void boost::call_once(boost::once_flag&amp;, Function) [with Function = void (*)()]?: /home/andyc/work/3rdParty/boost_1_39_0/boost/thread/once.hpp:27: instantiated from here /home/andyc/work/3rdParty/boost_1_39_0/boost/thread/pthread/once.hpp:66: error: exception handling disabled, use -fexceptions to enable &lt;/pre&gt; </p> </description> <category>Ticket</category> </item> <item> <author>Andrew Chittenden <andyc@…></author> <pubDate>Wed, 12 Aug 2009 09:30:57 GMT</pubDate> <title>attachment set https://svn.boost.org/trac10/ticket/3335 https://svn.boost.org/trac10/ticket/3335 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">once.hpp.patch</span> </li> </ul> <p> patch to boost/thread/pthread/once.hpp to make it BOOST_NO_EXCEPTIONS aware. </p> Ticket viboes Fri, 20 Nov 2009 11:01:07 GMT type, severity changed https://svn.boost.org/trac10/ticket/3335#comment:3 https://svn.boost.org/trac10/ticket/3335#comment:3 <ul> <li><strong>type</strong> <span class="trac-field-old">Bugs</span> → <span class="trac-field-new">Feature Requests</span> </li> <li><strong>severity</strong> <span class="trac-field-old">Problem</span> → <span class="trac-field-new">Not Applicable</span> </li> </ul> <p> Your patches just protect the throw statements, but what would be the behavior of the application with your patches. I think Boost.Threads has not an interface that allows to use it without exceptions, so I will consider this a feature request and not a Bug. </p> Ticket nigels@… Sat, 03 Apr 2010 19:04:57 GMT status, milestone changed; cc, resolution set https://svn.boost.org/trac10/ticket/3335#comment:4 https://svn.boost.org/trac10/ticket/3335#comment:4 <ul> <li><strong>cc</strong> <span class="trac-author">nigels@…</span> added </li> <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">duplicate</span> </li> <li><strong>milestone</strong> <span class="trac-field-old">Boost 1.40.0</span> → <span class="trac-field-new">Boost 1.43.0</span> </li> </ul> <p> Marking this as a duplicate of <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/2100" title="#2100: Feature Requests: thread fails to compile with -fno-exceptions (closed: fixed)">#2100</a> - thread fails to compile with -fno-exceptions. </p> <p> The good news is that this is just about resolved in boost svn trunk. </p> Ticket