[Bug c++/53121] New: Allow static_cast from pointer-to-vector to pointer-to-object
marc.glisse at normalesup dot org
gcc-bugzilla@gcc.gnu.org
Wed Apr 25 18:14:00 GMT 2012
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: unassigned@gcc.gnu.org
ReportedBy: marc.glisse@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*’
More information about the Gcc-bugs
mailing list