@@ -83,6 +83,10 @@ static int float8_cmp_internal(float8 a, float8 b);
8383static double sind_q1 (double x );
8484static double cosd_q1 (double x );
8585
86+ /* This is INTENTIONALLY NOT STATIC. Don't "fix" it. */
87+ void init_degree_constants (float8 thirty , float8 forty_five , float8 sixty ,
88+ float8 one_half , float8 one );
89+
8690#ifndef HAVE_CBRT
8791/*
8892 * Some machines (in particular, some versions of AIX) have an extern
@@ -1771,11 +1775,16 @@ dtan(PG_FUNCTION_ARGS)
17711775 * want exact results, we must ensure that none of the scaling constants used
17721776 * in the degree-based trig functions are computed that way.
17731777 *
1778+ * The whole approach fails if init_degree_constants() gets inlined into the
1779+ * call sites, since then constant-folding can happen anyway. Currently it
1780+ * seems sufficient to declare it non-static to prevent that. We have no
1781+ * expectation that other files will call this, but don't tell gcc that.
1782+ *
17741783 * Other hazards we are trying to forestall with this kluge include the
17751784 * possibility that compilers will rearrange the expressions, or compute
17761785 * some intermediate results in registers wider than a standard double.
17771786 */
1778- static void
1787+ void
17791788init_degree_constants (float8 thirty , float8 forty_five , float8 sixty ,
17801789 float8 one_half , float8 one )
17811790{
0 commit comments