diff options
Diffstat (limited to 'numpy')
-rw-r--r-- | numpy/core/src/multiarray/arraytypes.c.src | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/numpy/core/src/multiarray/arraytypes.c.src b/numpy/core/src/multiarray/arraytypes.c.src index d7d54a2c6..62a96e371 100644 --- a/numpy/core/src/multiarray/arraytypes.c.src +++ b/numpy/core/src/multiarray/arraytypes.c.src @@ -1153,12 +1153,17 @@ static void while (n--) { @fromtype@ f = *ip++; - @totype@ t = (@totype@)f; #if @supports_nat@ && @floatingpoint@ - /* Avoid undefined behaviour for NaN -> NaT */ + @totype@ t; + /* Avoid undefined behaviour and warning for NaN -> NaT */ if (npy_isnan(f)) { t = (@totype@)NPY_DATETIME_NAT; } + else { + t = (@totype@)f; + } +#else + @totype@ t = (@totype@)f; #endif *op++ = t; } @@ -1179,12 +1184,17 @@ static void while (n--) { @fromtype@ f = *ip; - @totype@ t = (@totype@)f; #if @supports_nat@ - /* Avoid undefined behaviour for NaN -> NaT */ + @totype@ t; + /* Avoid undefined behaviour and warning for NaN -> NaT */ if (npy_isnan(f)) { t = (@totype@)NPY_DATETIME_NAT; } + else { + t = (@totype@)f; + } +#else + @totype@ t = (@totype@)f; #endif *op++ = t; ip += 2; |