Boost C++ Libraries: Ticket #5545: ptr_container: unused parameter warnings if exceptions and asserts disabled https://svn.boost.org/trac10/ticket/5545 <p> With exceptions and asserts both disabled, <code>ptr_container_detail::reversible_ptr_container&lt;&gt;::enforce_null_policy()</code> generates unused-parameter warnings. Both its parameters are used only within an invocation of <code>BOOST_PTR_CONTAINER_THROW_EXCEPTION()</code>; with exceptions disabled, that expands to a <code>BOOST_ASSERT()</code>; with asserts disabled, that in turn becomes just <code>(void)0</code> (or equivalent). </p> <p> One way to fix this would be to make <code>BOOST_PTR_CONTAINER_THROW_EXCEPTION</code> expand to <code>BOOST_VERIFY</code> instead of <code>BOOST_ASSERT</code>, so that the parameters are still evaluated even when exceptions and asserts are disabled. This should make no difference when exceptions are enabled, or when exceptions are disabled but asserts are enabled. </p> <p> Minimal example: </p> <pre class="wiki">$ cat test.cpp #include &lt;boost/ptr_container/ptr_vector.hpp&gt; void foo(int *p) { boost::ptr_vector&lt;int&gt;().push_back(p); } $ g++ -W -Wall -fno-exceptions -Iboost -DNDEBUG -c test.cpp In file included from boost/boost/ptr_container/ptr_sequence_adapter.hpp:20, from boost/boost/ptr_container/ptr_vector.hpp:20, from test.cpp:1: boost/boost/ptr_container/detail/reversible_ptr_container.hpp: In instantiation of 'static void boost::ptr_container_detail::reversible_ptr_container&lt;Config, CloneAllocator&gt;::enforce_null_policy(const typename Config::value_type*, const char*) [with Config = boost::ptr_container_detail::sequence_config&lt;int, std::vector&lt;void*, std::allocator&lt;void*&gt; &gt; &gt;, CloneAllocator = boost::heap_clone_allocator]': boost/boost/ptr_container/ptr_sequence_adapter.hpp:246: instantiated from 'void boost::ptr_sequence_adapter&lt;T, VoidPtrSeq, CloneAllocator&gt;::push_back(typename boost::ptr_container_detail::reversible_ptr_container&lt;boost::ptr_container_detail::sequence_config&lt;T, VoidPtrSeq&gt;, CloneAllocator&gt;::value_type) [with T = int, VoidPtrSeq = std::vector&lt;void*, std::allocator&lt;void*&gt; &gt;, CloneAllocator = boost::heap_clone_allocator]' test.cpp:5: instantiated from here boost/boost/ptr_container/detail/reversible_ptr_container.hpp:260: warning: unused parameter 'x' boost/boost/ptr_container/detail/reversible_ptr_container.hpp:260: warning: unused parameter 'msg' </pre><p> (g++ will not emit the warnings if the boost headers are found in the system include directories.) </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/5545 Trac 1.4.3 timb@… Mon, 16 May 2011 12:03:45 GMT attachment set https://svn.boost.org/trac10/ticket/5545 https://svn.boost.org/trac10/ticket/5545 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">ptr_container_throw_exception.patch</span> </li> </ul> <p> Suggested fix </p> Ticket