/* { dg-do compile } */ /* { dg-options "-O2 -ffinite-loops -Wno-unused-result" } */ /* { dg-additional-options "-fdump-tree-cddce2 -fdump-tree-cddce3" } */ /* { dg-skip-if "requires hosted libstdc++ for string" { ! hostedlib } } */ #include #include #include #include #include using namespace std; int foo (vector &v, list &l, set &s, map &m) { for (vector::iterator it = v.begin (); it != v.end (); ++it) it->length(); for (list::iterator it = l.begin (); it != l.end (); ++it) it->length(); for (map::iterator it = m.begin (); it != m.end (); ++it) it->first + it->second.length(); for (set::iterator it0 = s.begin (); it0 != s.end(); ++it0) for (vector::reverse_iterator it1 = v.rbegin(); it1 != v.rend(); ++it1) { it0->length(); it1->length(); } return 0; } /* Adding __builtin_unreachable to std::string::size() prevents cddce2 from eliminating the loop early, see PR117764. */ /* { dg-final { scan-tree-dump-not "if" "cddce2" { xfail *-*-* } } } */ /* { dg-final { scan-tree-dump-not "if" "cddce3"} } */