This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author iroli
Recipients iroli
Date 2012-10-03.09:30:39
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1349256639.78.0.287581020931.issue16117@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2012-10-03 09:30:39irolisetrecipients: + iroli
2012-10-03 09:30:39irolisetmessageid: <1349256639.78.0.287581020931.issue16117@psf.upfronthosting.co.za>
2012-10-03 09:30:39irolilinkissue16117 messages
2012-10-03 09:30:39irolicreate