summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHood Chatham <roberthoodchatham@gmail.com>2022-01-16 09:38:29 -0800
committerHood Chatham <roberthoodchatham@gmail.com>2022-01-16 09:56:27 -0800
commit072253d217502f27e575beed75db83b8216e5b90 (patch)
tree7fd61f1f392962e25fff33d02a8ad7c5a2f790ac
parent4b985e2b85c7efc1d976835f74c3e45315c5ae28 (diff)
downloadnumpy-072253d217502f27e575beed75db83b8216e5b90.tar.gz
BUG: Fix comparator function signatures
The comparator functions are expected to have signature int f(void *, void*, PyArrayObject *). Some of the comparators drop the third argument because they don't use them. Because the comparators are unused, with most architectures this works fine. However, calling a function pointer that has been cast to have a different number of arguments is undefined in the C specification. With web assembly targets, it crashes at runtime. This fixes the comparators defined in arraytypes.c.src to all take three arguments. See also related work: 258ce2523ffad99be69afbd421d540086cb6bf61 23c05e6f1b392f80f749dbb4668b5e7b52aef014
-rw-r--r--numpy/core/src/multiarray/arraytypes.c.src6
1 files changed, 3 insertions, 3 deletions
diff --git a/numpy/core/src/multiarray/arraytypes.c.src b/numpy/core/src/multiarray/arraytypes.c.src
index 71808cc48..71401c60e 100644
--- a/numpy/core/src/multiarray/arraytypes.c.src
+++ b/numpy/core/src/multiarray/arraytypes.c.src
@@ -2849,7 +2849,7 @@ static int
#define LT(a,b) ((a) < (b) || ((b) != (b) && (a) ==(a)))
static int
-@TYPE@_compare(@type@ *pa, @type@ *pb)
+@TYPE@_compare(@type@ *pa, @type@ *pb, PyArrayObject *NPY_UNUSED(ap))
{
const @type@ a = *pa;
const @type@ b = *pb;
@@ -2869,7 +2869,7 @@ static int
static int
-C@TYPE@_compare(@type@ *pa, @type@ *pb)
+C@TYPE@_compare(@type@ *pa, @type@ *pb, PyArrayObject *NPY_UNUSED(ap))
{
const @type@ ar = pa[0];
const @type@ ai = pa[1];
@@ -2924,7 +2924,7 @@ C@TYPE@_compare(@type@ *pa, @type@ *pb)
*/
static int
-@TYPE@_compare(@type@ *pa, @type@ *pb)
+@TYPE@_compare(@type@ *pa, @type@ *pb, PyArrayObject *NPY_UNUSED(ap))
{
const @type@ a = *pa;
const @type@ b = *pb;