Skip to content

Commit

Permalink
Suppress warning "-Wstrict-aliasing" for GCC 5 and 6
Browse files Browse the repository at this point in the history
  • Loading branch information
dimztimz authored and horenmar committed Sep 15, 2022
1 parent c754308 commit 4b3defe
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/catch2/benchmark/catch_constructor.hpp
Expand Up @@ -54,14 +54,18 @@ namespace Catch {
template <typename U>
void destruct_on_exit(std::enable_if_t<!Destruct, U>* = nullptr) { }

T& stored_object() {
return *static_cast<T*>(static_cast<void*>(data));
}
#if defined( __GNUC__ ) && __GNUC__ <= 6
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wstrict-aliasing"
#endif
T& stored_object() { return *reinterpret_cast<T*>( data ); }

T const& stored_object() const {
return *static_cast<T const*>(static_cast<void const*>(data));
return *reinterpret_cast<T const*>( data );
}

#if defined( __GNUC__ ) && __GNUC__ <= 6
# pragma GCC diagnostic pop
#endif

alignas( T ) unsigned char data[sizeof( T )]{};
};
Expand Down

0 comments on commit 4b3defe

Please sign in to comment.