Debian Codegraph @

gcc/testsuite/g++.dg/opt/pr102970.C

raw
1 // { dg-do run }
2 // { dg-require-effective-target c++14 }
3 // { dg-options "-O2 -funroll-loops -fno-tree-vectorize" }
4 // { dg-skip-if "requires hosted libstdc++ for vector" { ! hostedlib } }
5
6 #include <vector>
7 #include <algorithm>
8 #include <cassert>
9
10 struct box {
11 box(int xmin, int xmax, int ymin, int ymax) noexcept
12 : m_xmin(xmin),
13 m_xmax(xmax),
14 m_ymin(ymin),
15 m_ymax(ymax) {
16 }
17
18 box(box const & o) noexcept
19 : m_xmin(o.m_xmin),
20 m_xmax(o.m_xmax),
21 m_ymin(o.m_ymin),
22 m_ymax(o.m_ymax) { }
23
24 int m_xmin;
25 int m_xmax;
26 int m_ymin;
27 int m_ymax;
28 };
29
30
31 int main() {
32 std::vector<box> vRects{ // requires 18 elements
33 { 900, 11, 22, 33 },
34 { 901, 11, 22, 33 },
35 { 902, 11, 22, 33 },
36 { 903, 11, 22, 33 },
37 { 704, 11, 22, 33 },
38 { 705, 11, 22, 33 },
39 { 706, 11, 22, 33 },
40 { 707, 11, 22, 33 },
41 { 808, 11, 22, 33 },
42 { 809, 11, 22, 33 },
43 { 810, 11, 22, 33 },
44 { 811, 11, 22, 33 },
45 { 812, 11, 22, 33 },
46 { 813, 11, 22, 33 },
47 { 814, 11, 22, 33 },
48 { 815, 11, 22, 33 },
49 { 816, 11, 22, 33 },
50 { 817, 11, 22, 33 },
51 { 818, 11, 22, 33 },
52 };
53
54 std::stable_sort(vRects.begin(), vRects.end(),
55 [](auto const &r1, auto const &r2) -> bool
56 {
57 if (r2.m_xmax==0||r2.m_ymin==0||r2.m_ymax==0){__builtin_abort();}
58 return r1.m_xmin < r2.m_xmin;
59 });
60 return 0;
61 }