Debian Codegraph @

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

raw
1 // { dg-do compile }
2 // { dg-additional-options "-Wno-return-type" }
3 // Reduced from boost-1.54
4
5 int pow(int, int);
6 int sqrt(int);
7
8 class PolicyA { };
9
10 template <class>
11 int max_value() { return 0x7fffffff; }
12
13 template <class>
14 int min_value() { return 1; }
15
16 void raise_denorm_error();
17
18 template <class T>
19 void raise_domain_error(int, int, const T &, const PolicyA &);
20
21 template <class>
22 int check_overflow(long double p1) {
23 long double __trans_tmp_2 = __builtin_fabsl(p1);
24 if (__trans_tmp_2 > max_value<int>())
25 return 1;
26 return 0;
27 }
28
29 template <class>
30 int check_underflow(long double p1) {
31 if (p1 && (double)p1)
32 return 1;
33 return 0;
34 }
35
36 template <class>
37 int check_denorm(long double p1) {
38 long double __trans_tmp_3 = __builtin_fabsl(p1);
39 if (__trans_tmp_3 < min_value<int>() && (double)p1) {
40 raise_denorm_error();
41 return 1;
42 }
43 return 0;
44 }
45
46 template <class, class>
47 double checked_narrowing_cast(long double p1) {
48 if (check_overflow<int>(p1))
49 return 0;
50 if (check_underflow<int>(p1))
51 return 0;
52 if (check_denorm<int>(p1))
53 return 0;
54 return (double)p1;
55 }
56
57 long double ellint_rf_imp(long double, long double, long double);
58
59 template <typename T, typename Policy>
60 T ellint_rj_imp(T p1, T p2, T p3, T p4, Policy &p5) {
61 T value, tolerance, P, S3;
62 if (p4)
63 return 0;
64 if (p3 || p1)
65 raise_domain_error(0, 0, 0, p5);
66 tolerance = pow(0, 0);
67 if (p4) {
68 T q = -p4;
69 {
70 long double q6 = ellint_rj_imp((long double)p1, (long double)(double)p2, (long double)(double)p3, (long double)(int)0, p5);
71 value = checked_narrowing_cast<T, int>(q6);
72 }
73 {
74 long double q7 = ellint_rf_imp((long double)p1, (long double)(double)p2, (long double)(double)p3);
75 value -= checked_narrowing_cast<T, const int>(q7);
76 }
77 value += p1 * p3 + p4 * q;
78 return value;
79 }
80 do {
81 P = p4 / p1;
82 if (0 < tolerance)
83 break;
84 sqrt(p3);
85 } while (1);
86 S3 = P * p2 * 0;
87 value = S3 / p1;
88 return value;
89 }
90
91 template <typename Policy>
92 void ellint_pi_imp4(double, double p3, Policy &p4) {
93 double x, y, z;
94 ellint_rj_imp(x, y, z, p3, p4);
95 }
96
97 template <typename Policy>
98 double ellint_pi_imp5(double, double p3, double p4, Policy &p5) {
99 double x, y, z, p;
100 if (p3 > 0)
101 return 0;
102 ellint_rj_imp(x, y, z, p, p5);
103 ellint_pi_imp4((double)0, p4, p5);
104 }
105
106 void boost_ellint_3f() {
107 PolicyA p4;
108 ellint_pi_imp5((double)0, (double)0, (double)0, p4);
109 }
110