Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r62614 - trunk/boost/function
From: jewillco_at_[hidden]
Date: 2010-06-08 19:55:26


Author: jewillco
Date: 2010-06-08 19:55:25 EDT (Tue, 08 Jun 2010)
New Revision: 62614
URL: http://svn.boost.org/trac/boost/changeset/62614

Log:
Removed all but one old-style cast, breaking GCC 2.95.3; fixes #3410
Text files modified:
   trunk/boost/function/function_base.hpp | 12 +++++++-----
   trunk/boost/function/function_template.hpp | 12 ++++++------
   2 files changed, 13 insertions(+), 11 deletions(-)

Modified: trunk/boost/function/function_base.hpp
==============================================================================
--- trunk/boost/function/function_base.hpp (original)
+++ trunk/boost/function/function_base.hpp 2010-06-08 19:55:25 EDT (Tue, 08 Jun 2010)
@@ -315,7 +315,7 @@
           if (op == clone_functor_tag || op == move_functor_tag) {
             const functor_type* in_functor =
               reinterpret_cast<const functor_type*>(&in_buffer.data);
- new ((void*)&out_buffer.data) functor_type(*in_functor);
+ new (reinterpret_cast<void*>(&out_buffer.data)) functor_type(*in_functor);
 
             if (op == move_functor_tag) {
               reinterpret_cast<functor_type*>(&in_buffer.data)->~Functor();
@@ -369,8 +369,10 @@
             // Clone the functor
             // GCC 2.95.3 gets the CV qualifiers wrong here, so we
             // can't do the static_cast that we should do.
+ // jewillco: Changing this to static_cast because GCC 2.95.3 is
+ // obsolete.
             const functor_type* f =
- (const functor_type*)(in_buffer.obj_ptr);
+ static_cast<const functor_type*>(in_buffer.obj_ptr);
             functor_type* new_f = new functor_type(*f);
             out_buffer.obj_ptr = new_f;
           } else if (op == move_functor_tag) {
@@ -474,7 +476,7 @@
             // GCC 2.95.3 gets the CV qualifiers wrong here, so we
             // can't do the static_cast that we should do.
             const functor_wrapper_type* f =
- (const functor_wrapper_type*)(in_buffer.obj_ptr);
+ static_cast<const functor_wrapper_type*>(in_buffer.obj_ptr);
             wrapper_allocator_type wrapper_allocator(static_cast<Allocator const &>(*f));
             wrapper_allocator_pointer_type copy = wrapper_allocator.allocate(1);
             wrapper_allocator.construct(copy, *f);
@@ -671,7 +673,7 @@
                       detail::function::check_functor_type_tag);
       // GCC 2.95.3 gets the CV qualifiers wrong here, so we
       // can't do the static_cast that we should do.
- return (const Functor*)(type_result.obj_ptr);
+ return static_cast<const Functor*>(type_result.obj_ptr);
     }
 
   template<typename F>
@@ -715,7 +717,7 @@
 public: // should be protected, but GCC 2.95.3 will fail to allow access
   detail::function::vtable_base* get_vtable() const {
     return reinterpret_cast<detail::function::vtable_base*>(
- reinterpret_cast<std::size_t>(vtable) & ~(std::size_t)0x01);
+ reinterpret_cast<std::size_t>(vtable) & ~static_cast<std::size_t>(0x01));
   }
 
   bool has_trivial_copy_and_destroy() const {

Modified: trunk/boost/function/function_template.hpp
==============================================================================
--- trunk/boost/function/function_template.hpp (original)
+++ trunk/boost/function/function_template.hpp 2010-06-08 19:55:25 EDT (Tue, 08 Jun 2010)
@@ -514,7 +514,7 @@
           if (f) {
             // should be a reinterpret cast, but some compilers insist
             // on giving cv-qualifiers to free functions
- functor.func_ptr = (void (*)())(f);
+ functor.func_ptr = reinterpret_cast<void (*)()>(f);
             return true;
           } else {
             return false;
@@ -563,7 +563,7 @@
         void
         assign_functor(FunctionObj f, function_buffer& functor, mpl::true_)
         {
- new ((void*)&functor.data) FunctionObj(f);
+ new (reinterpret_cast<void*>(&functor.data)) FunctionObj(f);
         }
         template<typename FunctionObj,typename Allocator>
         void
@@ -625,7 +625,7 @@
         assign_to(const reference_wrapper<FunctionObj>& f,
                   function_buffer& functor, function_obj_ref_tag)
         {
- functor.obj_ref.obj_ptr = (void *)f.get_pointer();
+ functor.obj_ref.obj_ptr = (void *)(f.get_pointer());
           functor.obj_ref.is_const_qualified = is_const<FunctionObj>::value;
           functor.obj_ref.is_volatile_qualified = is_volatile<FunctionObj>::value;
           return true;
@@ -677,7 +677,7 @@
 
     vtable_type* get_vtable() const {
       return reinterpret_cast<vtable_type*>(
- reinterpret_cast<std::size_t>(vtable) & ~(std::size_t)0x01);
+ reinterpret_cast<std::size_t>(vtable) & ~static_cast<size_t>(0x01));
     }
 
     struct clear_type {};
@@ -917,7 +917,7 @@
         if (boost::has_trivial_copy_constructor<Functor>::value &&
             boost::has_trivial_destructor<Functor>::value &&
             detail::function::function_allows_small_object_optimization<Functor>::value)
- value |= (std::size_t)0x01;
+ value |= static_cast<size_t>(0x01);
         vtable = reinterpret_cast<detail::function::vtable_base *>(value);
       } else
         vtable = 0;
@@ -951,7 +951,7 @@
         if (boost::has_trivial_copy_constructor<Functor>::value &&
             boost::has_trivial_destructor<Functor>::value &&
             detail::function::function_allows_small_object_optimization<Functor>::value)
- value |= (std::size_t)0x01;
+ value |= static_cast<std::size_t>(0x01);
         vtable = reinterpret_cast<detail::function::vtable_base *>(value);
       } else
         vtable = 0;


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk