modula2: M2MetaError.{def,mod} and P2SymBuild.mod further cleanup
[official-gcc.git] / gcc / testsuite / gcc.dg / pr89689.c
blob778643ab7a3a99d0a6a8aeb86321e59d3c34efbc
1 /* { dg-do compile } */
2 /* { dg-options "-O2 -Warray-bounds" } */
4 #include <string.h>
5 #include <assert.h>
6 #include <stdio.h>
8 static inline __attribute__((__artificial__)) void *a(char *c, const char *d, long n)
10 return __builtin___memcpy_chk(c, d, n, __builtin_object_size(c, 0));
12 typedef struct {
13 char *data;
14 int len;
15 } sb_t;
16 const char __sb_slop[1];
17 static void inline set0(sb_t *c)
19 if (c->data != __sb_slop)
20 c->data[0] = 0;
21 else
22 assert (c->data[0] == 0);
24 char buf[5];
25 sb_t l = {
26 .data = buf,
27 .len = 0
29 void o()
31 char *data = "abcd";
32 sb_t h = l;
33 set0(&h);
34 a(h.data, data, strlen(data));
35 printf("%s\n", h.data);
36 printf("%d\n", h.data == __sb_slop);
37 printf("%d\n", h.data == buf);
38 set0(&h);
40 int main(void) {
41 o();
42 return 0;