mirror of
https://github.com/catchorg/Catch2.git
synced 2024-12-22 19:33:29 +01:00
Suppress warning "-Wstrict-aliasing" for GCC 5 and 6
This commit is contained in:
parent
c75430834d
commit
4b3defe4af
@ -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 )]{};
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user