Fortran: Fix PR 47485.
[gcc.git] / gcc / testsuite / g++.dg / torture / pr104601.C
blobeaa61bd77c0c4cf1f9132aac4b92a554f29d4c0e
1 // PR tree-optimization/104601
2 // { dg-do run }
3 // { dg-options "-std=c++17 -Wno-unused-result" }
4 // { dg-skip-if "requires hosted libstdc++ for vector" { ! hostedlib } }
6 #include <algorithm>
7 #include <optional>
8 #include <vector>
10 inline std::optional<int>
11 foo (std::vector<int>::iterator b, std::vector<int>::iterator c,
12      std::optional<int> h (int))
14   std::optional<int> d;
15   find_if (b, c, [&](auto e) { d = h(e); return d; });
16   return d;
19 std::optional<int>
20 bar (int)
22   return 1;
25 int
26 main ()
28   std::vector<int> g(10);
29   auto b = g.begin ();
30   auto c = g.end ();
31   auto e = foo (b, c, bar);
32   if (!e)
33     __builtin_abort ();