summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/pr81345.c
blob: 14661f5dac34a1d0247e083036f609fbb424ca98 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
/* PR other/81345 - -Wall resets -Wstringop-overflow to 1 from the default 2
   { dg-do compile }
   { dg-options "-O2 -Wall -Wno-array-bounds" } */

char a[3];

void f (const char *s)
{
  __builtin_strncpy (a, s, sizeof a + 1);   /* { dg-warning "\\\[-Wstringop-overflow=]" } */
}

struct S { char a[3]; int i; };

void g (struct S *d, const char *s)
{
  __builtin_strncpy (d->a, s, sizeof d->a + 1);   /* { dg-warning "\\\[-Wstringop-overflow=]" } */
}