Author: Armin Rigo <[email protected]>
Branch:
Changeset: r914:a7550e27bbc4
Date: 2012-09-04 12:08 +0200
http://bitbucket.org/cffi/cffi/changeset/a7550e27bbc4/
Log: Fix.
diff --git a/c/_cffi_backend.c b/c/_cffi_backend.c
--- a/c/_cffi_backend.c
+++ b/c/_cffi_backend.c
@@ -3117,12 +3117,12 @@
assert(offset == 0);
offset = maxsize;
}
- offset = (offset + alignment - 1) & ~(alignment-1);
/* Like C, if the size of this structure would be zero, we compute it
as 1 instead. But for ctypes support, we allow the manually-
specified totalsize to be zero in this case. */
if (totalsize < 0) {
+ offset = (offset + alignment - 1) & ~(alignment-1);
totalsize = (offset == 0 ? 1 : offset);
}
else if (totalsize < offset) {
diff --git a/c/test_c.py b/c/test_c.py
--- a/c/test_c.py
+++ b/c/test_c.py
@@ -2061,3 +2061,9 @@
('i', BShort)])
assert sizeof(BUnion) == 4
assert alignof(BUnion) == 2
+
+def test_unaligned_struct():
+ BInt = new_primitive_type("int")
+ BStruct = new_struct_type("foo")
+ complete_struct_or_union(BStruct, [('b', BInt, -1, 1)],
+ None, 5, 1)
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit