http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53121

             Bug #: 53121
           Summary: Allow static_cast from pointer-to-vector to
                    pointer-to-object
    Classification: Unclassified
           Product: gcc
           Version: 4.8.0
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P3
         Component: c++
        AssignedTo: unassig...@gcc.gnu.org
        ReportedBy: marc.gli...@normalesup.org


Hello,

casting a __m128d* to a double* currently requires an ugly C cast. However,
this pointer cast is the official way to access the elements of the vector, so
I believe it should be allowed in a static_cast. Whether that should extend to
casts with references and arrays is a harder question, but the answer is
probably yes. Casts to sub-vectors (__m256d* to __m128d*) would be a bonus.

#include <x86intrin.h>
double* f(__m128d* x){
  return static_cast<double*>(x);
  // return (double*)(x);
}

v.cc: In function ‘double* f(__m128d*)’:
v.cc:3:32: error: invalid static_cast from type ‘__m128d* {aka __vector(2)
double*}’ to type ‘double*’

Reply via email to