internal compiler error
the appended code, when compiled with:
$ gcc -D_REENTRANT -g -ggdb3 -fno-strict-aliasing -fno-cond-mismatch \
-ffor-scope -Wno-cast-qual -Wall -Wmissing-prototypes \
-Wmissing-declarations -Winline -Wmissing-noreturn -Wredundant-decls \
-O6 -pipe -fstrength-reduce -fexpensive-optimizations -finline-functions \
-frerun-cse-after-loop -freg-struct-return -frerun-loop-opt -fgcse \
-fno-keep-static-consts -Wp,-MD,foo.pp -c gccerror.c -fPIC -DPIC \
-o gccerror.o
produces:
gccerror.c: In function `gsl_filter_tscheb2_rp':
gccerror.c:175: Internal compiler error:
gccerror.c:175: Internal compiler error, output_operand_lossage `invalid expression as operand'
>Release: 3.0.3 (Debian testing/unstable)
System: Linux birgrave 2.2.20 #1 SMP Thu Dec 13 10:05:39 CET 2001 i686 unknown
Architecture: i686
host: i386-pc-linux-gnu
build: i386-pc-linux-gnu
target: i386-pc-linux-gnu
$ gcc --version
2.95.4
(doesn't seem to be reproducable with gcc-3.0.3 btw)
---
ciaoTJ
/* LGPL */
#include <math.h>
typedef struct _GslComplex GslComplex;
struct _GslComplex
{
double re;
double im;
};
static inline GslComplex
gsl_complex (double re,
double im)
{
GslComplex r;
r.re = re;
r.im = im;
return r;
}
static inline GslComplex
gsl_complex_add (GslComplex c1,
GslComplex c2)
{
return gsl_complex (c1.re + c2.re, c1.im + c2.im);
}
static inline GslComplex
gsl_complex_add3 (GslComplex c1,
GslComplex c2,
GslComplex c3)
{
return gsl_complex (c1.re + c2.re + c3.re, c1.im + c2.im + c3.im);
}
static inline GslComplex
gsl_complex_sub (GslComplex c1,
GslComplex c2)
{
return gsl_complex (c1.re - c2.re, c1.im - c2.im);
}
#define GSL_PI \
(3.1415926535897932384626433832795029)
static inline double
gsl_trans_freq2s (double w)
{
return tan (w / 2.);
}
static inline GslComplex
gsl_complex_div (GslComplex a,
GslComplex b)
{
GslComplex c;
if (fabs (b.re) >= fabs (b.im))
{
double r = b.im / b.re, den = b.re + r * b.im;
c.re = (a.re + r * a.im) / den;
c.im = (a.im - r * a.re) / den;
}
else
{
double r = b.re / b.im, den = b.im + r * b.re;
c.re = (a.re * r + a.im) / den;
c.im = (a.im * r - a.re) / den;
}
return c;
}
static inline double
gsl_trans_zepsilon2ss (double zepsilon)
{
double e2 = (1.0 - zepsilon) * (1.0 - zepsilon);
/* 1___ _________________
* | \ | 1.0
* |-----\<---- 1 - zepsilon zepsilon = \ | ----------------
* |_______\________________ \| 1 + sepsilon^2
*/
return sqrt ((1.0 - e2) / e2);
}
static inline GslComplex
gsl_trans_s2z (GslComplex s)
{
/* 1 + (Td/2) * s
* z = ----------------
* 1 - (Td/2) * s
*/
GslComplex one = { 1, 0 };
return gsl_complex_div (gsl_complex_add (one, s), gsl_complex_sub (one, s));
/* return gsl_complex_div (gsl_complex_sub (s, one), gsl_complex_add (s, one)); */
}
static double
tschebyscheff_eval (unsigned int degree,
double x)
{
double td = x, td_m_1 = 1;
unsigned int d = 1;
/* eval polynomial for a certain x */
if (degree == 0)
return 1;
while (d < degree)
{
double td1 = 2 * x * td - td_m_1;
td_m_1 = td;
td = td1;
d++;
}
return td;
}
void
gsl_filter_tscheb2_rp (unsigned int iorder,
double c_freq, /* 1..pi */
double steepness,
double epsilon,
GslComplex *roots, /* [0..iorder-1] */
GslComplex *poles);
void
gsl_filter_tscheb2_rp (unsigned int iorder,
double c_freq, /* 1..pi */
double steepness,
double epsilon,
GslComplex *roots, /* [0..iorder-1] */
GslComplex *poles)
{
double pi = GSL_PI, order = iorder;
double r_freq = c_freq * steepness;
double kappa_c = gsl_trans_freq2s (c_freq);
double kappa_r = gsl_trans_freq2s (r_freq);
double tepsilon;
double alpha;
double beta_mul = pi / (2.0 * order);
GslComplex root;
unsigned int i;
if (!(r_freq < GSL_PI))
return;
epsilon = gsl_trans_zepsilon2ss (epsilon);
tepsilon = epsilon * tschebyscheff_eval (iorder, kappa_r / kappa_c);
alpha = asinh (tepsilon) / order;
/* construct poles polynomial from tschebyscheff polynomial */
for (i = 1; i <= iorder; i++)
{
double t = (i << 1) + iorder - 1;
double beta = t * beta_mul;
root.re = sinh (alpha) * cos (beta);
root.im = cosh (alpha) * sin (beta);
root = gsl_complex_div (gsl_complex (kappa_r, 0), root);
root = gsl_trans_s2z (root);
poles[i - 1] = root;
}
/* construct roots polynomial from tschebyscheff polynomial */
for (i = 1; i <= iorder; i++)
{
double t = (i << 1) - 1;
GslComplex root = gsl_complex (0, cos (t * beta_mul));
if (fabs (root.im) > 1e-14)
{
root = gsl_complex_div (gsl_complex (kappa_r, 0), root);
root = gsl_trans_s2z (root);
}
else
root = gsl_complex (-1, 0);
roots[i - 1] = root;
}
}
Reply to: