New submission from Roland Lezuo:
class Int(ctypes.Structure):
_fields_ = [ ("_i", ctypes.c_uint64),
("undef", ctypes.c_bool)]
class Int {
public:
Int();
Int(uint64_t i);
uint64_t _i;
bool undef;
};
extern "C" Int foo(const Int& a , const Int& b , const Int& c)
{
ret = ...
return Int(ret);
}
(gdb) p ret
$3 = 16
(gdb) fin
Run till exit from #0 BVSignExtend (a=..., b=..., c=...) at foo.hpp:130
0x00007ffff784eea4 in ffi_call_unix64 () from
/usr/lib/python2.7/lib-dynload/_ctypes.so
Value returned is $4 = {_i = 18577824, undef = 16}
My guess: The value 18577824 was not expected to be on the stack.
The following actions "solve" the problem:
1) add another int the class Int (after bool) and adopt _fields_ accordingly.
2) in foo C++ function:
Int reti = Int(ret);
return reti;
Because of the "above" solutions I strongly suspect a bug in ctypes.
----------
components: ctypes
messages: 171876
nosy: iroli
priority: normal
severity: normal
status: open
title: python2.7.3 struct misaligned when returned
versions: Python 2.7
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue16117>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com