1 // PR c++/87122
2 // { dg-do run { target c++14 } }
3 // { dg-options "" }
4 
5 extern "C" void abort ();
6 struct S { int a, b; };
7 int c;
8 
9 template <int N>
10 void
foo()11 foo ()
12 {
13   S x[4] = { { N, 2 }, { 3, 4 }, { 5, 6 }, { 7, 8 } };
14   auto f = [](auto & y) {
15     for (auto & [ u, v ] : y)	// { dg-warning "structured bindings only available with" "" { target c++14_down } }
16       {
17 	if ((u & 1) != 1 || v != u + 1 || u < N || u > 7 || (c & (1 << u))
18 	    || &u != &y[v / 2 - 1].a || &v != &y[v / 2 - 1].b)
19 	  abort ();
20 	c |= 1 << u;
21       }
22   };
23   f (x);
24 }
25 
26 int
main()27 main ()
28 {
29   foo<1> ();
30   if (c != 0xaa)
31     abort ();
32 }
33