Subject: [Ffc] Bug in evaluate_basis_derivatives

From: Anders Logg <[email-masked]>
Date: Mon, 25 Jan 2010 15:00:25 +0100

There seems to be a bug in evaluate_basis_derivatives.

To reproduce the bug, run the regression test and then enter the
output directory and run ./P5tet.bin

The bug seems to be somewhere inside this loop:

  for (unsigned int r = 0; r < 4; r++)
  {
    for (unsigned int s = 0; s < (4 - r); s++)
    {
      for (unsigned int t = 1; t < (5 - r - s); t++)
      {
          rr = (1 + t + (1 + r + s + t)*(2 + r + s + t)*(3 + r + s +
          t)/6 + (1 + s + t)*(2 + s + t)*(2 + s + t)/2);
          ss = (t + (1 + r + s + t)*(r + s + t)*(2 + r + s + t)/6 + (1
          + s + t)*(s + t)*(1 + s + t)/2);
          tt = (t + (r + s + t-1)*(r + s + t)*(1 + r + s + t)/6 + (s +
          t-1)*(s + t)*(s + t)/2-1);
          tmp5 = (1 + 2*r + 2*s + 2*t)*(2 + 2*r + 2*s + 2*t)/(2*(1 + t
          + 2*r + 2*s)*(1 + t));
          tmp6 = (1 + 2*r + 2*s + 2*t)*(4*r*r + 4*s*s + 8*r*s)/(2*(1 +
          t + 2*r + 2*s)*(1 + t)*(2*r + 2*s + 2*t));
          tmp7 = (2 + 2*r + 2*s + 2*t)*(t + 2*r + 2*s)*t/((1 + t + 2*r
          + 2*s)*(1 + t)*(2*r + 2*s + 2*t));
          basisvalues[rr] = (basisvalues[ss]*(tmp6 + tmp5*z) -
          basisvalues[tt]*tmp7);
        }// end loop over 't'
      }// end loop over 's'
    }// end loop over 'r'

Somewhere here, the variable num_derivatives changes value from 1 to
1080542285.

To recompile the test if you make changes to the generated code for
testing, just run

  g++ `pkg-config --cflags ufc-1` -Wall -Werror -g -o P5tet.bin P5tet.cpp

Any ideas what goes wrong?

--
Anders