summaryrefslogtreecommitdiffstats
path: root/Include/cpython
diff options
context:
space:
mode:
authorPetr Viktorin <encukou@gmail.com>2020-12-29 23:32:07 (GMT)
committerGitHub <noreply@github.com>2020-12-29 23:32:07 (GMT)
commit056c08211b402b4dbc1530a9de9d00ad5309909f (patch)
treecd9e3eb367dde397f56fea413677eebcb4df1b34 /Include/cpython
parent2edfc86f69d8a74f4821974678f664ff94a9dc22 (diff)
downloadcpython-056c08211b402b4dbc1530a9de9d00ad5309909f.zip
cpython-056c08211b402b4dbc1530a9de9d00ad5309909f.tar.gz
cpython-056c08211b402b4dbc1530a9de9d00ad5309909f.tar.bz2
bpo-40052: Fix alignment issue in PyVectorcall_Function() (GH-23999)
``` In file included from /usr/include/python3.8/Python.h:147: In file included from /usr/include/python3.8/abstract.h:837: /usr/include/python3.8/cpython/abstract.h:91:11: error: cast from 'char *' to 'vectorcallfunc *' (aka 'struct _object *(**)(struct _object *, struct _object *const *, unsigned long, struct _object *)') increases required alignment from 1 to 8 [-Werror,-Wcast-align] ptr = (vectorcallfunc*)(((char *)callable) + offset); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1 error generated. ``` Co-Authored-By: Andreas Schneider <asn@cryptomilk.org> Co-Authored-By: Antoine Pitrou <antoine@python.org>
Diffstat (limited to 'Include/cpython')
-rw-r--r--Include/cpython/abstract.h6
1 files changed, 3 insertions, 3 deletions
diff --git a/Include/cpython/abstract.h b/Include/cpython/abstract.h
index b5b6e48..1083942 100644
--- a/Include/cpython/abstract.h
+++ b/Include/cpython/abstract.h
@@ -63,7 +63,7 @@ PyVectorcall_Function(PyObject *callable)
{
PyTypeObject *tp;
Py_ssize_t offset;
- vectorcallfunc *ptr;
+ vectorcallfunc ptr;
assert(callable != NULL);
tp = Py_TYPE(callable);
@@ -73,8 +73,8 @@ PyVectorcall_Function(PyObject *callable)
assert(PyCallable_Check(callable));
offset = tp->tp_vectorcall_offset;
assert(offset > 0);
- ptr = (vectorcallfunc *)(((char *)callable) + offset);
- return *ptr;
+ memcpy(&ptr, (char *) callable + offset, sizeof(ptr));
+ return ptr;
}
/* Call the callable object 'callable' with the "vectorcall" calling