doc: Update Cygwin web link
[official-gcc.git] / gcc / testsuite / gcc.dg / Warray-bounds-3.c
blobf119502f0250eda4cf32f5173c8c0c8054f103d6
1 /* { dg-do compile } */
2 /* { dg-options "-O2 -Warray-bounds" } */
3 /* { dg-skip-if "exceeds eBPF stack limit" { bpf-*-* } } */
4 /* based on PR 31227 */
6 typedef __SIZE_TYPE__ size_t;
8 extern size_t strlen (const char *);
10 struct iovec
12 void *iov_base;
13 size_t iov_len;
16 struct S
18 const char *abday[7];
19 const char *day[7];
20 const char *abmon[12];
21 const char *mon[12];
22 const char *am_pm[2];
25 extern void foo (size_t, struct iovec *);
27 void
28 bar (struct S *time)
30 struct iovec iov[43];
31 size_t cnt;
32 iov[0].iov_base = (void *) "abc";
33 iov[0].iov_len = 3;
35 iov[1].iov_base = (void *) "def";
36 iov[1].iov_len = 3;
38 for (cnt = 0; cnt < 7; ++cnt)
40 iov[2 + cnt].iov_base = (void *) (time->abday[cnt] ?: "");
41 iov[2 + cnt].iov_len = strlen (iov[2 + cnt].iov_base) + 1;
44 for (; cnt < 14; ++cnt)
46 iov[2 + cnt].iov_base = (void *) (time->day[cnt - 7] ?: "");
47 iov[2 + cnt].iov_len = strlen (iov[2 + cnt].iov_base) + 1;
50 for (; cnt < 26; ++cnt)
52 iov[2 + cnt].iov_base = (void *) (time->abmon[cnt - 14] ?: "");
53 iov[2 + cnt].iov_len = strlen (iov[2 + cnt].iov_base) + 1;
56 for (; cnt < 38; ++cnt)
58 iov[2 + cnt].iov_base = (void *) (time->mon[cnt - 26] ?: "");
59 iov[2 + cnt].iov_len = strlen (iov[2 + cnt].iov_base) + 1;
62 for (; cnt < 40; ++cnt)
64 iov[2 + cnt].iov_base = (void *) (time->am_pm[cnt - 38] ?: "");
65 iov[2 + cnt].iov_len = strlen (iov[2 + cnt].iov_base) + 1;
68 foo (2 + cnt, iov);
71 struct malloc_chunk {
72 long prev_size;
73 long size;
74 struct malloc_chunk* fd;
75 struct malloc_chunk* bk;
77 typedef struct malloc_chunk* mchunkptr;
78 struct malloc_state {
79 mchunkptr top;
80 mchunkptr last_remainder;
81 mchunkptr bins[128 * 2 - 2];
83 #define bin_at(m, i) \
84 (mchunkptr) (((char *) &((m)->bins[((i) - 1) * 2])) \
85 - __builtin_offsetof (struct malloc_chunk, fd))
87 void malloc_init_state(struct malloc_state *av)
89 int i;
90 mchunkptr bin;
92 for (i = 1; i < 128; ++i) {
93 bin = bin_at(av,i);
94 bin->fd = bin->bk = bin;
98 typedef unsigned short WCHAR;
99 typedef WCHAR *LPWSTR;
101 static void g(LPWSTR dest, int len) {
102 dest[len-1] = 0;
105 void f() {
106 WCHAR szPathW[260];
108 g(szPathW, 260);