Skip to content

Commit

Permalink
Fix taking address of temporary array
Browse files Browse the repository at this point in the history
Error was:

  dtype_transfer.c:2979:28: error: taking address of temporary array
   2979 |                 (char *[2]){main_src, main_dst}, &block_size,
        |                            ^~~~~~~~~~~~~~~~~~~~
  • Loading branch information
juztamau5 committed Nov 9, 2022
1 parent 28e9227 commit e3db792
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions numpy/core/src/multiarray/dtype_transfer.c
Expand Up @@ -2951,9 +2951,11 @@ _strided_to_strided_multistep_cast(

if (castdata->from.func != NULL) {
npy_intp out_stride = castdata->from.descriptors[1]->elsize;
char *const data[2] = {src, castdata->from_buffer};
npy_intp strides[2] = {src_stride, out_stride};
if (castdata->from.func(&castdata->from.context,
(char *[2]){src, castdata->from_buffer}, &block_size,
(npy_intp [2]){src_stride, out_stride},
data, &block_size,
strides,
castdata->from.auxdata) != 0) {
/* TODO: Internal buffer may require cleanup on error. */
return -1;
Expand All @@ -2975,18 +2977,22 @@ _strided_to_strided_multistep_cast(
main_dst_stride = dst_stride;
}

char *const data[2] = {main_src, main_dst};
npy_intp strides[2] = {main_src_stride, main_dst_stride};
if (castdata->main.func(&castdata->main.context,
(char *[2]){main_src, main_dst}, &block_size,
(npy_intp [2]){main_src_stride, main_dst_stride},
data, &block_size,
strides,
castdata->main.auxdata) != 0) {
/* TODO: Internal buffer may require cleanup on error. */
return -1;
}

if (castdata->to.func != NULL) {
char *const data[2] = {main_dst, dst};
npy_intp strides[2] = {main_dst_stride, dst_stride};
if (castdata->to.func(&castdata->to.context,
(char *[2]){main_dst, dst}, &block_size,
(npy_intp [2]){main_dst_stride, dst_stride},
data, &block_size,
strides,
castdata->to.auxdata) != 0) {
return -1;
}
Expand Down

0 comments on commit e3db792

Please sign in to comment.