diff options
| author | Dimitrij Mijoski | 2022-09-14 22:48:58 +0200 |
|---|---|---|
| committer | Martin Hořeňovský | 2022-09-15 13:40:16 +0200 |
| commit | 4b3defe4afe32dbf4c8feaf49b97907129e05834 (patch) | |
| tree | 0fd1ee721f5ceef254e4d64ceef4b88eb7ce79c9 /src/catch2/benchmark | |
| parent | c75430834df6bbde9cfe7962c7dc38fd0bb0c030 (diff) | |
| download | catch3-4b3defe4afe32dbf4c8feaf49b97907129e05834.tar.gz | |
Suppress warning "-Wstrict-aliasing" for GCC 5 and 6
Diffstat (limited to 'src/catch2/benchmark')
| -rw-r--r-- | src/catch2/benchmark/catch_constructor.hpp | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/src/catch2/benchmark/catch_constructor.hpp b/src/catch2/benchmark/catch_constructor.hpp index 86bbfb00..f2a743ab 100644 --- a/src/catch2/benchmark/catch_constructor.hpp +++ b/src/catch2/benchmark/catch_constructor.hpp @@ -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 )]{}; }; |