Debian Codegraph @

gcc/testsuite/g++.dg/torture/pr54498.C

raw
1 // { dg-do run }
2 // { dg-additional-options "-fno-tree-sra" }
3 // { dg-skip-if "requires hosted libstdc++ for complex" { ! hostedlib } }
4
5 #include <complex>
6
7 using namespace std;
8
9 class bar_src {
10 public:
11 bar_src() : next(0) {}
12 virtual ~bar_src() { delete next; }
13
14 bar_src *next;
15 };
16
17 class foo_src : public bar_src {
18 public:
19 foo_src(double f, double fwidth, double s = 5.0);
20 virtual ~foo_src() {}
21
22 private:
23 double freq, width, peak_time, cutoff;
24 };
25
26
27 foo_src::foo_src(double f, double fwidth, double s) {
28 freq = f; width = 1/fwidth; cutoff = s*width; peak_time = cutoff;
29 }
30
31 complex<double> do_ft2(int i) __attribute__ ((noinline));
32
33 complex<double> do_ft2(int i) {
34 return i == 0 ? complex<double>(-491.697,887.05) : complex<double>(-491.692,887.026);
35 }
36
37 void foo(void) {
38 complex<double> prev_ft = 0.0, ft = 0.0;
39 for (int i=0; i < 2; i++) {
40 prev_ft = ft;
41 {
42 foo_src src(1.0, 1.0 / 20);
43 ft = do_ft2(i);
44 }
45 if (i > 0)
46 {
47 double a = abs(ft - prev_ft);
48 if (a < 0.024 || a > 0.025)
49 __builtin_abort ();
50 }
51 }
52 }
53
54 int main()
55 {
56 foo();
57 return 0;
58 }