diff options
| author | Sebastian Berg <sebastian@sipsolutions.net> | 2022-05-04 17:18:29 +0200 |
|---|---|---|
| committer | Sebastian Berg <sebastian@sipsolutions.net> | 2022-06-13 09:36:57 -0700 |
| commit | d41f1de03794bee3f722e6921bc5fce5c04cce04 (patch) | |
| tree | 79e7cfa84b1575ca402730bc2212ce62824f7dc2 /numpy | |
| parent | 9c74efa571dc0ac5fd18799105fd678cd8042282 (diff) | |
| download | numpy-d41f1de03794bee3f722e6921bc5fce5c04cce04.tar.gz | |
BUG: Add volatile to float -> datetime casts to work around compiler deficiencies
Diffstat (limited to 'numpy')
| -rw-r--r-- | numpy/core/src/multiarray/arraytypes.c.src | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/numpy/core/src/multiarray/arraytypes.c.src b/numpy/core/src/multiarray/arraytypes.c.src index ca06643ce..a9f8dfdd2 100644 --- a/numpy/core/src/multiarray/arraytypes.c.src +++ b/numpy/core/src/multiarray/arraytypes.c.src @@ -1197,8 +1197,12 @@ static void @totype@ *op = output; while (n--) { - @fromtype@ f = *ip++; #if @supports_nat@ && @floatingpoint@ + /* + * volatile works around clang (and gcc sometimes) not branching + * correctly, leading to floating point errors in the test suite. + */ + volatile @fromtype@ f = *ip++; @totype@ t; /* Avoid undefined behaviour and warning for NaN -> NaT */ if (npy_isnan(f)) { @@ -1208,7 +1212,7 @@ static void t = (@totype@)f; } #else - @totype@ t = (@totype@)f; + @totype@ t = (@totype@)*ip++; #endif *op++ = t; } @@ -1228,8 +1232,12 @@ static void @totype@ *op = output; while (n--) { - @fromtype@ f = *ip; #if @supports_nat@ + /* + * volatile works around clang (and gcc sometimes) not branching + * correctly, leading to floating point errors in the test suite. + */ + volatile @fromtype@ f = *ip; @totype@ t; /* Avoid undefined behaviour and warning for NaN -> NaT */ if (npy_isnan(f)) { @@ -1239,7 +1247,7 @@ static void t = (@totype@)f; } #else - @totype@ t = (@totype@)f; + @totype@ t = (@totype@)*ip; #endif *op++ = t; ip += 2; |
