[PR c++/84702] ICE with default tmpl arg of overload set
[official-gcc.git] / gcc / testsuite / g++.dg / pr79095-2.C
blob9dabc7ee277f135ecd0056f2ff33bec25604555f
1 /* { dg-do compile } */
2 /* { dg-options "-Wall -O3" } */
4 typedef long unsigned int size_t;
6 inline void
7 fill (int *p, size_t n, int)
9   while (n--)
10     *p++ = 0;
13 struct B
15   int* p0, *p1, *p2;
17   size_t size () const {
18     return size_t (p1 - p0);
19   }
21   void resize (size_t n) {
22     if (n > size())
23       append (n - size());
24   }
26   void append (size_t n)
27   {
28     if (size_t (p2 - p1) >= n)   {
29       fill (p1, n, 0);
30     }
31   }
34 void foo (B &b)
36     b.resize (b.size () - 1);
39 /* If b.size() == 0, then the argument to b.resize is -1U (it overflowed).
40    This will result calling "fill" which turns into a memset with a bogus
41    length argument.  We want to make sure we warn, which multiple
42    things.  First the ldist pass converted the loop into a memset,
43    cprop and simplifications made the length a constant and the static
44    analysis pass determines it's a bogus size to pass to memset.  */
45 /* { dg-warning "exceeds maximum object size" "" { target *-*-* } 0 } */