X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/2a32b8071b301260644a8ac0286797197e3d0ebb..3017880eff92f202f26262fbcdf1744cb620e3e3:/include/wx/any.h diff --git a/include/wx/any.h b/include/wx/any.h index 26f36e7c68..4ddd7b4c1c 100644 --- a/include/wx/any.h +++ b/include/wx/any.h @@ -182,7 +182,11 @@ public: static const T& GetValue(const wxAnyValueBuffer& buf) { - return *(reinterpret_cast(&buf.m_buffer[0])); + // Breaking this code into two lines should supress + // GCC's 'type-punned pointer will break strict-aliasing rules' + // warning. + const T* value = reinterpret_cast(&buf.m_buffer[0]); + return *value; } }; @@ -323,13 +327,17 @@ public: \ virtual ~wxAnyValueTypeImpl() { } \ static void SetValue(const T& value, wxAnyValueBuffer& buf) \ { \ - *(reinterpret_cast(&buf.m_buffer[0])) = \ - static_cast(value); \ + void* voidPtr = reinterpret_cast(&buf.m_buffer[0]); \ + UseDataType* dptr = reinterpret_cast(voidPtr); \ + *dptr = static_cast(value); \ } \ static T GetValue(const wxAnyValueBuffer& buf) \ { \ - return static_cast( \ - *(reinterpret_cast(&buf.m_buffer[0]))); \ + const void* voidPtr = \ + reinterpret_cast(&buf.m_buffer[0]); \ + const UseDataType* sptr = \ + reinterpret_cast(voidPtr); \ + return static_cast(*sptr); \ } \ }; @@ -759,7 +767,7 @@ public: in release ones. @remarks This template function does not work on some older compilers - (such as Visual C++ 6.0). For full compiler ccompatibility + (such as Visual C++ 6.0). For full compiler compatibility please use wxANY_AS(any, T) macro instead. */ // FIXME-VC6: remove this hack when VC6 is no longer supported