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 meador.inge
Recipients ezberch, meador.inge, ned.deily, ronaldoussoren, vstinner
Date 2012-02-06.01:29:18
SpamBayes Score 5.935874e-06
Marked as misclassified No
Message-id <1328491761.54.0.522141769908.issue13370@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2012-02-06 01:29:21meador.ingesetrecipients: + meador.inge, ronaldoussoren, vstinner, ned.deily, ezberch
2012-02-06 01:29:21meador.ingesetmessageid: <1328491761.54.0.522141769908.issue13370@psf.upfronthosting.co.za>
2012-02-06 01:29:20meador.ingelinkissue13370 messages
2012-02-06 01:29:18meador.ingecreate