[Boost-bugs] [Boost C++ Libraries] #5545: ptr_container: unused parameter warnings if exceptions and asserts disabled

Subject: [Boost-bugs] [Boost C++ Libraries] #5545: ptr_container: unused parameter warnings if exceptions and asserts disabled
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2011-05-16 12:02:38


#5545: ptr_container: unused parameter warnings if exceptions and asserts disabled
------------------------------+---------------------------------------------
 Reporter: timb@… | Owner: nesotto
     Type: Bugs | Status: new
Milestone: To Be Determined | Component: ptr_container
  Version: Boost 1.39.0 | Severity: Problem
 Keywords: |
------------------------------+---------------------------------------------
 With exceptions and asserts both disabled,
 `ptr_container_detail::reversible_ptr_container<>::enforce_null_policy()`
 generates unused-parameter warnings. Both its parameters are used only
 within an invocation of `BOOST_PTR_CONTAINER_THROW_EXCEPTION()`; with
 exceptions disabled, that expands to a `BOOST_ASSERT()`; with asserts
 disabled, that in turn becomes just `(void)0` (or equivalent).

 One way to fix this would be to make `BOOST_PTR_CONTAINER_THROW_EXCEPTION`
 expand to `BOOST_VERIFY` instead of `BOOST_ASSERT`, 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.

 Minimal example:

 {{{
 $ cat test.cpp
 #include <boost/ptr_container/ptr_vector.hpp>

 void foo(int *p)
 {
     boost::ptr_vector<int>().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<Config,
 CloneAllocator>::enforce_null_policy(const typename Config::value_type*,
 const char*) [with Config =
 boost::ptr_container_detail::sequence_config<int, std::vector<void*,
 std::allocator<void*> > >, CloneAllocator = boost::heap_clone_allocator]':
 boost/boost/ptr_container/ptr_sequence_adapter.hpp:246: instantiated
 from 'void boost::ptr_sequence_adapter<T, VoidPtrSeq,
 CloneAllocator>::push_back(typename
 boost::ptr_container_detail::reversible_ptr_container<boost::ptr_container_detail::sequence_config<T,
 VoidPtrSeq>, CloneAllocator>::value_type) [with T = int, VoidPtrSeq =
 std::vector<void*, std::allocator<void*> >, 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'
 }}}

 (g++ will not emit the warnings if the boost headers are found in the
 system include directories.)

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/5545>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:06 UTC