* asan.c (create_cond_insert_point): Maintain profile.
[official-gcc.git] / gcc / testsuite / gcc.dg / Warray-bounds-3.c
blob773f4633dc799329c79b02f50257e0ffa2f90b24
1 /* { dg-do compile } */
2 /* { dg-options "-O2 -Warray-bounds" } */
3 /* based on PR 31227 */
5 typedef __SIZE_TYPE__ size_t;
7 extern size_t strlen (const char *);
9 struct iovec
11 void *iov_base;
12 size_t iov_len;
15 struct S
17 const char *abday[7];
18 const char *day[7];
19 const char *abmon[12];
20 const char *mon[12];
21 const char *am_pm[2];
24 extern void foo (size_t, struct iovec *);
26 void
27 bar (struct S *time)
29 struct iovec iov[43];
30 size_t cnt;
31 iov[0].iov_base = (void *) "abc";
32 iov[0].iov_len = 3;
34 iov[1].iov_base = (void *) "def";
35 iov[1].iov_len = 3;
37 for (cnt = 0; cnt < 7; ++cnt)
39 iov[2 + cnt].iov_base = (void *) (time->abday[cnt] ?: "");
40 iov[2 + cnt].iov_len = strlen (iov[2 + cnt].iov_base) + 1;
43 for (; cnt < 14; ++cnt)
45 iov[2 + cnt].iov_base = (void *) (time->day[cnt - 7] ?: "");
46 iov[2 + cnt].iov_len = strlen (iov[2 + cnt].iov_base) + 1;
49 for (; cnt < 26; ++cnt)
51 iov[2 + cnt].iov_base = (void *) (time->abmon[cnt - 14] ?: "");
52 iov[2 + cnt].iov_len = strlen (iov[2 + cnt].iov_base) + 1;
55 for (; cnt < 38; ++cnt)
57 iov[2 + cnt].iov_base = (void *) (time->mon[cnt - 26] ?: "");
58 iov[2 + cnt].iov_len = strlen (iov[2 + cnt].iov_base) + 1;
61 for (; cnt < 40; ++cnt)
63 iov[2 + cnt].iov_base = (void *) (time->am_pm[cnt - 38] ?: "");
64 iov[2 + cnt].iov_len = strlen (iov[2 + cnt].iov_base) + 1;
67 foo (2 + cnt, iov);
70 struct malloc_chunk {
71 long prev_size;
72 long size;
73 struct malloc_chunk* fd;
74 struct malloc_chunk* bk;
76 typedef struct malloc_chunk* mchunkptr;
77 struct malloc_state {
78 mchunkptr top;
79 mchunkptr last_remainder;
80 mchunkptr bins[128 * 2 - 2];
82 #define bin_at(m, i) \
83 (mchunkptr) (((char *) &((m)->bins[((i) - 1) * 2])) \
84 - __builtin_offsetof (struct malloc_chunk, fd))
86 void malloc_init_state(struct malloc_state *av)
88 int i;
89 mchunkptr bin;
91 for (i = 1; i < 128; ++i) {
92 bin = bin_at(av,i);
93 bin->fd = bin->bk = bin;
97 typedef unsigned short WCHAR;
98 typedef WCHAR *LPWSTR;
100 static void g(LPWSTR dest, int len) {
101 dest[len-1] = 0;
104 void f() {
105 WCHAR szPathW[260];
107 g(szPathW, 260);