[PR c++/84702] ICE with default tmpl arg of overload set
[official-gcc.git] / gcc / testsuite / g++.dg / ext / strncpy-chk1.C
blob8f8822b67b6a976c5c195276c13ad53bc8622417
1 // PR c++/40502 - [4.5 Regression] crash in cp_diagnostic_starter
2 // { dg-do compile }
3 // { dg-options "-O2" }
4 // { dg-skip-if "packed attribute missing for struct A" { "epiphany-*-*" } }
6 struct A { char x[12], y[35]; };
7 struct B { char z[50]; };
9 inline void
10 foo (char *dest, const char *__restrict src, __SIZE_TYPE__ n)
12   // This triggers a -Wstringop-overflow warning (pruned below).
13   __builtin___strncpy_chk (dest, src, n, __builtin_object_size (dest, 0));
16 void bar (const char *, int);
18 inline void
19 baz (int i)
21   char s[128], t[32];
22   bar (s, 0);
23   bar (t, i);
24   A a;
25   B b;
26   foo (a.y, b.z, 36);
29 void
30 test ()
32   baz (0);
35 // { dg-prune-output "\\\[-Wstringop-overflow=]" }