[issue26628] Undefined behavior calling C functions with ctypes.Union arguments

Thomas report at bugs.python.org
Thu Mar 24 09:27:15 EDT 2016


Thomas added the comment:

So after some more pondering about the issue I read the documentation again:

> Warning ctypes does not support passing unions or structures with bit-fields to functions by value.

Previously I always read this as 'does not support passing unions with bit-fields'... I guess it is meant otherwise. IMHO this should be formulated more clearly, like: "does not support passing structures with bit-fields or unions to functions by value.".

Also I would strongly argue to generally prohibit this with an exception instead of just trying if libffi maybe handles this on the current architecture. libffi clearly does not support unions. This just introduces subtle bugs.

See also: https://github.com/atgreen/libffi/issues/33

----------
title: Segfault in cffi with ctypes.union argument -> Undefined behavior calling C functions with ctypes.Union arguments

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue26628>
_______________________________________


More information about the Python-bugs-list mailing list