summaryrefslogtreecommitdiff
path: root/tests/headers
diff options
context:
space:
mode:
authorEmilio Cobos Álvarez <emilio@crisal.io>2020-11-28 01:33:32 +0100
committerEmilio Cobos Álvarez <emilio@crisal.io>2020-11-28 03:14:51 +0100
commit19142ac6b3d8ee4fc5686d6f30b77e660026e528 (patch)
tree7be336cb2bfd34e6a8c844b868efb4332aba9c4f /tests/headers
parent6a5726eac514b49ec8a9f8360ed5d0d73da9feb7 (diff)
struct_layout: Fix field offset computation for packed(n) structs.
This can cause unnecessary padding to be computed otherwise at the end of the struct. With repr(packed(n)), a field can have padding to adjacent fields as long as its alignment is less than n. So reuse the code we have to align to a field layout, aligning to the struct layout instead. Fixes #1934
Diffstat (limited to 'tests/headers')
-rw-r--r--tests/headers/packed-n-with-padding.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/tests/headers/packed-n-with-padding.h b/tests/headers/packed-n-with-padding.h
new file mode 100644
index 00000000..8a6233b5
--- /dev/null
+++ b/tests/headers/packed-n-with-padding.h
@@ -0,0 +1,8 @@
+#pragma pack(push, 2)
+struct Packed {
+ char a;
+ short b;
+ char c;
+ int d;
+};
+#pragma pack(pop)