1 /* $NetBSD: d_packed_structs.c,v 1.6 2023/08/05 10:00:59 rillig Exp $ */ 2 # 3 "d_packed_structs.c" 3 4 /* packed tests */ 5 6 /* lint1-extra-flags: -X 351 */ 7 8 struct in_addr { 9 int x; 10 }; 11 struct ip_timestamp { 12 char ipt_code; 13 char ipt_len; 14 char ipt_ptr; 15 unsigned int 16 ipt_flg: 4, 17 ipt_oflw: 4; 18 union ipt_timestamp { 19 int ipt_time[1]; 20 struct ipt_ta { 21 struct in_addr ipt_addr; 22 int ipt_time; 23 } ipt_ta[1]__packed; 24 } ipt_timestamp__packed; 25 } __packed; 26 27 typedef struct __packed { 28 int x; 29 } t; 30 31 struct x { 32 char c; 33 long long l; 34 } __packed; 35 36 struct y { 37 char c; 38 long long l; 39 }; 40 41 int a[sizeof(struct y) - sizeof(struct x) - 1]; 42 43 /* expect+1: error: negative array dimension (-9) [20] */ 44 typedef int sizeof_x[-(int)sizeof(struct x)]; 45 /* expect+1: error: negative array dimension (-16) [20] */ 46 typedef int sizeof_y[-(int)sizeof(struct y)]; 47