1 /* PR tree-optimization/89644 - False-positive -Warray-bounds diagnostic
4 { dg-options "-O2 -Wall -ftrack-macro-expansion=0" } */
6 #define NONSTR __attribute__ ((nonstring))
8 typedef __SIZE_TYPE__
size_t;
10 size_t strlen (const char*);
11 extern char* stpncpy (char*, const char*, size_t);
12 extern char* strncpy (char*, const char*, size_t);
14 void sink (char*, ...);
18 char a
[6] NONSTR
= { 1, 2, 3, 4, 5, 6 };
20 strncpy (a
, s
, sizeof a
); /* { dg-bogus "\\\[-Warray-bounds" } */
26 char a
[6] NONSTR
= { 1, 2, 3, 4, 5, 6 };
28 strncpy (a
, s
, sizeof a
); /* { dg-bogus "\\\[-Warray-bounds" } */
34 char a
[6] NONSTR
= { 1, 2, 3, 4, 5, 6 };
35 char b
[6] NONSTR
= { 6, 5, 4, 3, 2, 1 };
36 strncpy (a
, b
+ 1, 5); /* { dg-bogus "\\\[-Warray-bounds" } */
42 char a
[6] NONSTR
= { 1, 2, 3, 4, 5, 6 };
43 char b
[6] NONSTR
= { 6, 5, 4, 3, 2, 1 };
44 strncpy (a
, b
+ 2, 4); /* { dg-bogus "\\\[-Warray-bounds" } */
48 void f4 (NONSTR
char *d
)
50 char b
[6] NONSTR
= { 6, 5, 4, 3, 2, 1 };
51 strncpy (d
, b
+ 3, 3); /* { dg-bogus "\\\[-Warray-bounds" } */
58 char a
[6] NONSTR
= { 1, 2, 3, 4, 5, 6 };
60 stpncpy (a
, s
, sizeof a
); /* { dg-bogus "\\\[-Warray-bounds" } */
66 char a
[6] NONSTR
= { 1, 2, 3, 4, 5, 6 };
69 p
= stpncpy (a
, s
, sizeof a
); /* { dg-bogus "\\\[-Warray-bounds" } */
75 char a
[6] NONSTR
= { 1, 2, 3, 4, 5, 6 };
76 char b
[6] NONSTR
= { 6, 5, 4, 3, 2, 1 };
77 stpncpy (a
, b
+ 1, 5); /* { dg-bogus "\\\[-Warray-bounds" } */
83 char a
[6] NONSTR
= { 1, 2, 3, 4, 5, 6 };
84 char b
[6] NONSTR
= { 6, 5, 4, 3, 2, 1 };
85 char *p
= stpncpy (a
, b
+ 2, 4); /* { dg-bogus "\\\[-Warray-bounds" } */
89 void g4 (NONSTR
char *d
)
91 char b
[6] NONSTR
= { 6, 5, 4, 3, 2, 1 };
92 char *p
= stpncpy (d
, b
+ 3, 3); /* { dg-bogus "\\\[-Warray-bounds" } */