title: C multiplication or addition floats results NaN
body: <p>I'm using libresample at program. After some time (about 50 min) it crashes in lib's function lrsFilterUD() at one workstation.</p>
  
  <pre><code>float lrsFilterUD(float Imp[],  /* impulse response */
                float ImpD[], /* impulse response deltas */
                UWORD Nwing,  /* len of one wing of filter */
                BOOL Interp,  /* Interpolate coefs using deltas? */
                float *Xp,    /* Current sample */
                double Ph,    /* Phase */
                int Inc,    /* increment (1 for right wing or -1 for left) */
                double dhb)
  {
     float a;
     float *Hp, *Hdp, *End;
     float v, t;
     double Ho;
  
     v = 0.0; /* The output value */
     Ho = Ph*dhb;
     End = &amp;Imp[Nwing];
     if (Inc == 1)        /* If doing right wing...              */
     {                      /* ...drop extra coeff, so when Ph is  */
        End--;            /*    0.5, we don't do too many mult's */
        if (Ph == 0)      /* If the phase is zero...           */
           Ho += dhb;     /* ...then we've already skipped the */
     }                         /*    first sample, so we must also  */
                          /*    skip ahead in Imp[] and ImpD[] */
  
     if (Interp)
        while ((Hp = &amp;Imp[(int)Ho]) &lt; End) {
           t = *Hp;       /* Get IR sample */
           Hdp = &amp;ImpD[(int)Ho];  /* get interp bits from diff table*/
           a = Ho - floor(Ho);      /* a is logically between 0 and 1 */
           t += (*Hdp)*a; /* t is now interp'd filter coeff */
           t *= *Xp;      /* Mult coeff by input sample */
           v += t;            /* The filter output */
           Ho += dhb;     /* IR step */
           Xp += Inc;     /* Input signal step. NO CHECK ON BOUNDS */
        }
     else 
        while ((Hp = &amp;Imp[(int)Ho]) &lt; End) {
           dprintf("while begin: Hp = %p, *Hp = %a, (int)Ho = %d, Imp[(int)Ho] = %a, &amp;Imp[(int)Ho] = %p", Hp, *Hp, (int)Ho, Imp[(int)Ho], &amp;Imp[(int)Ho]);
           t = *Hp;       /* Get IR sample */
           dprintf("before t = %a, *Xp = %a, Xp = %p", t, *Xp, Xp);
           t *= *Xp;      /* Mult coeff by input sample */
           dprintf("after2 t = %a, v = %a", t, v);
           v += t;            /* The filter output */
           dprintf("v = %a", v);
           Ho += dhb;     /* IR step */
           Xp += Inc;     /* Input signal step. NO CHECK ON BOUNDS */
        }
  
     return v;
  }
  </code></pre>
  
  <p>I logged values of t, *Xp, Xp before and after multiplication:</p>
  
  <pre><code>while begin: Hp = 0xaf5daa8, *Hp = -0.009034, (int)Ho = 16384, Imp[(int)Ho] = -0.009034, &amp;Imp[(int)Ho] = 0xaf5daa8
  before multiplication t = -0.009034, *Xp = 0.000000, Xp = 0xaebe9b8
  after multiplication t = nan
  </code></pre>
  
  <p>This code run many times, there are the same t and Xp values before crash:</p>
  
  <pre><code>before multiplication t = -0.009034, *Xp = 0.000000, Xp = 0xaebe9c8
  after multiplication t = -0.000000, v = 282.423676
  </code></pre>
  
  <p>Or another case with addition:</p>
  
  <pre><code>before addition t = -460.799988, v = 0.000000
  after addition v = nan
  </code></pre>
  
  <p>What could be causing nan? This is compiled with gcc 4.1.2 on Linux.</p>
  
  <p><strong>Update:</strong> Print variables as %a. Result:</p>
  
  <pre><code>//t = 0x1.2806bap+2
  //Hp = 0xb3bb870
  t = *Hp;
  //t = nan
  </code></pre>
  
  <p><strong>Update 2:</strong> There is no such issue if code is compiled by icpc. So is there compiler specific issue?</p>