Meador Inge <[email protected]> added the comment:
So I have debugged the first failure and it has to do with the sign extending
of 'signed char' parameters. The first test case basically does this:
_dll = CDLL(_ctypes_test.__file__)
_dll.tf_b.restype = c_byte
_dll.tf_b.argtypes = (c_byte,)
_dll.tf_b(-126)
where 'tf_b' is defined in C code like:
signed char tf_b(signed char c) { return c/3; }
Clang with -O3 generates code for 'tf_b' like:
0x0000000100000ed0 <tf_b+0>: push %rbp
0x0000000100000ed1 <tf_b+1>: mov %rsp,%rbp
0x0000000100000ed4 <tf_b+4>: movslq %edi,%rax
0x0000000100000ed7 <tf_b+7>: imul $0x55555556,%rax,%rax
0x0000000100000ede <tf_b+14>: mov %rax,%rcx
0x0000000100000ee1 <tf_b+17>: shr $0x3f,%rcx
0x0000000100000ee5 <tf_b+21>: shr $0x20,%rax
0x0000000100000ee9 <tf_b+25>: add %ecx,%eax
0x0000000100000eeb <tf_b+27>: movsbl %al,%eax
0x0000000100000eee <tf_b+30>: pop %rbp
0x0000000100000eef <tf_b+31>: retq
See how 'movslq' is used to sign extend the first argument? Since the first
argument is a 'signed char', that should be 'movsbq'. I am pretty sure this is
a clang bug.
I am going to see if this is fixed in later versions of clang. I will also
search the clang tracker to see if this has been reported.
----------
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue13370>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com