Permalink
Browse files

BUG: Attempt to fix sparc segfault (gh-2668)

  • Loading branch information...
1 parent c97f405 commit e0dd41c0a7a4ec75f6f00dc6ef33f67964ea14b3 @mwiebe mwiebe committed Dec 6, 2012
Showing with 14 additions and 0 deletions.
  1. +14 −0 numpy/core/src/multiarray/dtype_transfer.c
@@ -3582,6 +3582,13 @@ PyArray_GetDTypeTransferFunction(int aligned,
PyArray_ISNBO(dst_dtype->byteorder)) {
if (PyArray_EquivTypenums(src_type_num, dst_type_num)) {
+ /*
+ * For complex numbers, the alignment is smaller than the
+ * type size, so we turn off the aligned flag then.
+ */
+ if (src_dtype->kind == 'c' || dst_dtype->kind == 'c') {
+ aligned = 0;
+ }
*out_stransfer = PyArray_GetStridedCopyFn(aligned,
src_stride, dst_stride,
src_itemsize);
@@ -3678,6 +3685,13 @@ PyArray_GetDTypeTransferFunction(int aligned,
/* This is a straight copy */
if (src_itemsize == 1 || PyArray_ISNBO(src_dtype->byteorder) ==
PyArray_ISNBO(dst_dtype->byteorder)) {
+ /*
+ * For complex numbers, the alignment is smaller than the
+ * type size, so we turn off the aligned flag then.
+ */
+ if (src_dtype->kind == 'c' || dst_dtype->kind == 'c') {
+ aligned = 0;
+ }
*out_stransfer = PyArray_GetStridedCopyFn(aligned,
src_stride, dst_stride,
src_itemsize);

0 comments on commit e0dd41c

Please sign in to comment.