// PR tree-optimization/104601 // { dg-do run } // { dg-options "-std=c++17 -Wno-unused-result" } // { dg-skip-if "requires hosted libstdc++ for vector" { ! hostedlib } } #include #include #include inline std::optional foo (std::vector::iterator b, std::vector::iterator c, std::optional h (int)) { std::optional d; find_if (b, c, [&](auto e) { d = h(e); return d; }); return d; } std::optional bar (int) { return 1; } int main () { std::vector g(10); auto b = g.begin (); auto c = g.end (); auto e = foo (b, c, bar); if (!e) __builtin_abort (); }