Michael Felt <mich...@felt.demon.nl> added the comment: On 04/08/2016 10:58, Martin Panter wrote: > Martin Panter added the comment: > > Okay, so to be clear, I am assuming XLC supports all of the following fields, > and uses unsigned bit fields by default: > > struct UNSIGNED_BITS { > unsigned int AU: 1; > int A: 1; /* Equivalent to unsigned int */ > signed int AS: 1; > unsigned short MU: 1; > short M: 1; /* Equivalent to unsigned short; triggers warning */ > }; > > and that it cannot compile the following: > > struct SIGNED_BITS { > signed short MS: 1; /* Not supported */ > }; > > Attached is what I think a patch to resolve this would look like. However it > needs a line in Modules/_ctypes/_ctypes_test.c completed to detect the > compiler: > > #ifndef /* Something to identify XLC */ > > Can you figure out a way to test for XLC (but not GCC, which the AIX buildbot > uses),
I'll figure this out. HOWEVER, Just want to mention that both parts of C_Test are failing when using xlc (i.e., on "A" and "M"). Note line 40 and 51. (Have not done the compiler detect part yet, so it still returns something != 999) +33 class C_Test(unittest.TestCase): +34 +35 def test_ints(self): +36 for i in range(512): +37 for name in "ABCDEFGHI": +38 b = BITS() +39 setattr(b, name, i) +40 self.assertEqual(getattr(b, name), func(byref(b), name.encode('ascii'))) +41 +42 def test_shorts(self): +43 b = BITS() +44 name = "M" +45 if func(byref(b), name.encode('ascii')) == 999: +46 self.skipTest("Compiler does not support signed short bitfields") +47 for i in range(256): +48 for name in "MNOPQRS": +49 b = BITS() +50 setattr(b, name, i) +51 self.assertEqual(getattr(b, name), func(byref(b), name.encode('ascii'))) +52 ====================================================================== FAIL: test_ints (ctypes.test.test_bitfields.C_Test) ---------------------------------------------------------------------- Traceback (most recent call last): File "/data/prj/python/git/xlc-python3-3.7/Lib/ctypes/test/test_bitfields.py", line 40, in test_ints self.assertEqual(getattr(b, name), func(byref(b), name.encode('ascii'))) AssertionError: -1 != 1 ====================================================================== FAIL: test_shorts (ctypes.test.test_bitfields.C_Test) ---------------------------------------------------------------------- Traceback (most recent call last): File "/data/prj/python/git/xlc-python3-3.7/Lib/ctypes/test/test_bitfields.py", line 51, in test_shorts self.assertEqual(getattr(b, name), func(byref(b), name.encode('ascii'))) AssertionError: -1 != 1 ---------------------------------------------------------------------- > and then try my patch out? Hopefully you see no more compiler warnings, > test_ints() should now pass, again - not done the changes to _ctypes_test.c yet - so maybe the test_ints() will pass after that. > and test_shorts() should be skipped. > > ---------- > keywords: +patch > Added file: http://bugs.python.org/file44005/disable-signed-short.patch > > _______________________________________ > Python tracker <rep...@bugs.python.org> > <http://bugs.python.org/issue27643> > _______________________________________ ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue27643> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com