From: kronbichler Date: Wed, 12 Dec 2012 14:19:47 +0000 (+0000) Subject: Replace reinterpret_cast by static_cast in access to individual elements of vectorize... X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d896492148e06cfc2b650efc9f53e71b2eb2cec2;p=dealii-svn.git 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 --- 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); } /**