Skip to content

Commit

Permalink
Fix for WEC2013 (#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
apolukhin committed Jan 20, 2017
1 parent 97ac230 commit 529ff73
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions include/boost/dll/detail/aggressive_ptr_cast.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Copyright 2014 Renato Tegon Forti, Antony Polukhin.
// Copyright 2015-2016 Antony Polukhin.
// Copyright 2015-2017 Antony Polukhin.
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt
Expand All @@ -21,9 +21,14 @@
#include <boost/type_traits/remove_pointer.hpp>
#include <boost/type_traits/remove_reference.hpp>
#include <boost/utility/enable_if.hpp>
#include <boost/cstdint.hpp> // boost::uintptr_t
#include <cstring> // std::memcpy

// Logic from boost/log/detail/header.hpp
#if defined(__GNUC__) && !(defined(__INTEL_COMPILER) || defined(__ICL) || defined(__ICC) || defined(__ECC)) \
&& (__GNUC__ * 100 + __GNUC_MINOR__) >= 406
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wpedantic"
#endif
namespace boost { namespace dll { namespace detail {

// GCC warns when reinterpret_cast between function pointer and object pointer occur.
Expand All @@ -48,9 +53,7 @@ BOOST_FORCEINLINE typename boost::disable_if_c<boost::is_member_pointer<To>::val
"Pointer to function and pointer to object differ in size on your platform."
);

return reinterpret_cast<To>(
reinterpret_cast<boost::uintptr_t>(v)
);
return reinterpret_cast<To>(v);
}

template <class To, class From>
Expand All @@ -73,12 +76,8 @@ BOOST_FORCEINLINE typename boost::disable_if_c<!boost::is_reference<To>::value |
);

return static_cast<To>(
*reinterpret_cast<typename boost::remove_reference<To>::type*>(
*reinterpret_cast<boost::uintptr_t*>(
reinterpret_cast<unsigned char*>(
v
)
)
**reinterpret_cast<typename boost::remove_reference<To>::type**>(
v
)
);
}
Expand Down Expand Up @@ -124,6 +123,11 @@ BOOST_FORCEINLINE typename boost::disable_if_c<boost::is_member_pointer<To>::val
return 0;
}

#if defined(__GNUC__) && !(defined(__INTEL_COMPILER) || defined(__ICL) || defined(__ICC) || defined(__ECC)) \
&& (__GNUC__ * 100 + __GNUC_MINOR__) >= 406
# pragma GCC diagnostic pop
#endif

}}} // boost::dll::detail

#endif // BOOST_DLL_DETAIL_AGGRESSIVE_PTR_CAST_HPP
Expand Down

0 comments on commit 529ff73

Please sign in to comment.