Ticket #362 (new wishlist)

Opened 8 years ago

misplaced static types in src/libsrc/util/fft99.c

Reported by: baker Owned by: somebody
Priority: minor Milestone: All Platforms
Component: ALL modules Version: 7.8
Keywords: util fft99.c Cc:


When I enabled the Intel C compiler option to check for questionable usage, it reports a potential loss of significant bits in fact() in fft99.c:

fft99.c(567): warning #2259: non-pointer conversion from "double" to "long" may lose significant bits
    max = sqrt((double) nn);

max is a long, so all that is really needed is to cast the sqrt() result as a (long).

However, the declaration of max:

  /* Local variables */
  static long k, l, nn, inc, max;

makes all the local variables static. I see the same all over this file.

FFTs are supposed to be fast. You don't want variables that can be assigned to a register for their entire lifetime declared static.

This is old code -- it says it was translated by f2c. I bet the static is from the f2c translation. Old Fortran code used to assume that all variables were static, and initialized to zero. That was never legal Fortran. But, a lot of old Fortran code relies on that. Maybe it is time to replace it. Like, with FFTW.

Note: See TracTickets for help on using tickets.