Skip to content

Commit 165ec47

Browse files
Daniel Kroeningtautschnig
Daniel Kroening
authored andcommitted
Test alignment of unions
1 parent 6c56f19 commit 165ec47

File tree

1 file changed

+27
-0
lines changed
  • regression/ansi-c/Union_Padding1

1 file changed

+27
-0
lines changed

regression/ansi-c/Union_Padding1/main.c

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,33 @@ STATIC_ASSERT(sizeof(union some_union4)==3);
6262

6363
#endif
6464

65+
#ifdef _MSC_VER
66+
67+
union some_union5
68+
{
69+
int i;
70+
};
71+
72+
STATIC_ASSERT(__alignof(union some_union5)==1);
73+
74+
#else
75+
76+
union some_union5
77+
{
78+
int i;
79+
};
80+
81+
union some_union6
82+
{
83+
int i;
84+
} __attribute__((__packed__));
85+
86+
// Packing may affect alignment
87+
STATIC_ASSERT(_Alignof(union some_union5)==4);
88+
STATIC_ASSERT(_Alignof(union some_union6)==1);
89+
90+
#endif
91+
6592
int main()
6693
{
6794
}

0 commit comments

Comments
 (0)