From d896492148e06cfc2b650efc9f53e71b2eb2cec2 Mon Sep 17 00:00:00 2001 From: kronbichler Date: Wed, 12 Dec 2012 14:19:47 +0000 Subject: [PATCH] Replace reinterpret_cast by static_cast in access to individual elements of vectorized data types. git-svn-id: https://svn.dealii.org/trunk@27799 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/include/deal.II/base/vectorization.h | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/deal.II/include/deal.II/base/vectorization.h b/deal.II/include/deal.II/base/vectorization.h index 28403b7d48..f5830f514f 100644 --- a/deal.II/include/deal.II/base/vectorization.h +++ b/deal.II/include/deal.II/base/vectorization.h @@ -103,7 +103,10 @@ public: operator [] (const unsigned int comp) { AssertIndexRange (comp, 4); - return *(reinterpret_cast(&data)+comp); + // __m256d stores doubles in adjacent memory blocks. to access one double + // data field at a time, first cast the address of the given data field to + // void* and then back to double*. + return *(static_cast(static_cast(&data))+comp); } /** @@ -113,7 +116,7 @@ public: operator [] (const unsigned int comp) const { AssertIndexRange (comp, 4); - return *(reinterpret_cast(&data)+comp); + return *(static_cast(static_cast(&data))+comp); } /** @@ -286,7 +289,7 @@ public: operator [] (const unsigned int comp) { AssertIndexRange (comp, 8); - return *(reinterpret_cast(&data)+comp); + return *(static_cast(static_cast(&data))+comp); } /** @@ -296,7 +299,7 @@ public: operator [] (const unsigned int comp) const { AssertIndexRange (comp, 8); - return *(reinterpret_cast(&data)+comp); + return *(static_cast(static_cast(&data))+comp); } /** @@ -472,7 +475,7 @@ public: operator [] (const unsigned int comp) { AssertIndexRange (comp, 2); - return *(reinterpret_cast(&data)+comp); + return *(static_cast(static_cast(&data))+comp); } /** @@ -482,7 +485,7 @@ public: operator [] (const unsigned int comp) const { AssertIndexRange (comp, 2); - return *(reinterpret_cast(&data)+comp); + return *(static_cast(static_cast(&data))+comp); } /** @@ -651,7 +654,7 @@ public: operator [] (const unsigned int comp) { AssertIndexRange (comp, 4); - return *(reinterpret_cast(&data)+comp); + return *(static_cast(static_cast(&data))+comp); } /** @@ -661,7 +664,7 @@ public: operator [] (const unsigned int comp) const { AssertIndexRange (comp, 4); - return *(reinterpret_cast(&data)+comp);; + return *(static_cast(static_cast(&data))+comp); } /** -- 2.39.5