Ticket #3780: boost-function-convert-reinterpret_cast-gcc-system-header.diff

File boost-function-convert-reinterpret_cast-gcc-system-header.diff, 2.6 KB (added by Dean Michael Berris, 13 years ago)

GCC System Header and reinterpret_cast conversion to static_cast and friends.

  • boost/function/function_base.hpp

     
    22
    33//  Copyright Douglas Gregor 2001-2006
    44//  Copyright Emil Dotchevski 2007
     5//  Copyright Dean Michael Berris 2009
    56//  Use, modification and distribution is subject to the Boost Software License, Version 1.0.
    67//  (See accompanying file LICENSE_1_0.txt or copy at
    78//  http://www.boost.org/LICENSE_1_0.txt)
     
    4445#   pragma warning( disable : 4127 ) // "conditional expression is constant"
    4546#endif       
    4647
     48#if defined(__GNUC__)
     49// Because GCC complains of strict aliasing problems, we make it
     50// treat the header as a system header, becoming more forgiving with
     51// treating implementation details that may be potentially harmful.
     52# pragma GCC system_header
     53#endif
     54
    4755// Define BOOST_FUNCTION_STD_NS to the namespace that contains type_info.
    4856#ifdef BOOST_NO_STD_TYPEINFO
    4957// Embedded VC++ does not have type_info in namespace std
     
    314322        {
    315323          if (op == clone_functor_tag || op == move_functor_tag) {
    316324            const functor_type* in_functor =
    317               reinterpret_cast<const functor_type*>(&in_buffer.data);
     325              static_cast<const functor_type*>(static_cast<void*>(&in_buffer.data));
    318326            new ((void*)&out_buffer.data) functor_type(*in_functor);
    319327
    320328            if (op == move_functor_tag) {
    321               reinterpret_cast<functor_type*>(&in_buffer.data)->~Functor();
     329              static_cast<functor_type*>(static_cast<void*>(&in_buffer.data))->~Functor();
    322330            }
    323331          } else if (op == destroy_functor_tag) {
    324332            // Some compilers (Borland, vc6, ...) are unhappy with ~functor_type.
    325             reinterpret_cast<functor_type*>(&out_buffer.data)->~Functor();
     333            static_cast<functor_type*>(static_cast<void*>(&out_buffer.data))->~Functor();
    326334          } else if (op == check_functor_type_tag) {
    327335            const detail::sp_typeinfo& check_type
    328336              = *out_buffer.type.type;
     
    714722
    715723public: // should be protected, but GCC 2.95.3 will fail to allow access
    716724  detail::function::vtable_base* get_vtable() const {
    717     return reinterpret_cast<detail::function::vtable_base*>(
    718              reinterpret_cast<std::size_t>(vtable) & ~(std::size_t)0x01);
     725    return static_cast<detail::function::vtable_base*>(
     726            (void*)(
     727             (std::size_t(static_cast<void*>(vtable)) & ~(std::size_t(0x01)))
     728             )
     729            );
    719730  }
    720731
    721732  bool has_trivial_copy_and_destroy() const {