c: Implement C23 nullptr (N3042)
[official-gcc.git] / gcc / testsuite / gcc.dg / sso-14.c
blob7b1590ad03a7bb83bd88c5caf54cd9ab7310e053
1 /* PR c/100920 */
2 /* Testcase by George Thopas <george.thopas@gmail.com> */
4 /* { dg-do compile } */
5 /* { dg-require-effective-target alloca } */
7 #include <stddef.h>
8 #include <stdlib.h>
9 #include <string.h>
11 #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
12 #define REV_ENDIANNESS __attribute__((scalar_storage_order("big-endian")))
13 #else
14 #define REV_ENDIANNESS __attribute__((scalar_storage_order("little-endian")))
15 #endif
17 struct s_1 {
18 int val;
19 } REV_ENDIANNESS;
21 typedef struct s_1 t_1;
23 struct s_2 {
24 char val;
25 } REV_ENDIANNESS;
27 typedef struct s_2 t_2;
29 struct s12 {
30 t_1 a[1];
31 t_2 b[1];
32 } REV_ENDIANNESS;
34 typedef struct s12 t_s12;
36 union u12 {
37 t_1 a[1];
38 t_2 b[1];
39 } REV_ENDIANNESS;
41 typedef union u12 t_u12;
43 int main(void)
45 t_s12 *msg1 = __builtin_alloca(10);
46 t_u12 *msg2 = __builtin_alloca(10);
47 int same;
49 msg1 = malloc (sizeof (t_s12));
50 msg2 = malloc (sizeof (t_s12));
52 memset (msg1, 0, sizeof (t_s12));
53 memcpy (msg2, msg1, sizeof (t_s12));
54 same = memcmp (msg1, msg2, sizeof (t_s12));
56 return 0;