title: Is "final" clause of "task" directive correctly?
body: <p>I'm trying to understand how to make <code>final</code> clause of the <code>task</code> actually work and I found the following example of code in <a href="http://docs.oracle.com/cd/E24457_01/html/E21996/glmpw.html" rel="nofollow">this</a> link.</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;omp.h&gt;
  
  #define THRESHOLD 5
  
  int fib(int n)
  {
    int i, j;
  
    if (n&lt;2)
    return n;
  
    #pragma omp task shared(i) firstprivate(n) final(n &lt;= THRESHOLD)
    i=fib(n-1);
  
    #pragma omp task shared(j) firstprivate(n) final(n &lt;= THRESHOLD)
    j=fib(n-2);
  
    #pragma omp taskwait
    return i+j;
  }
  
  
  int main()
  {
    int n = 30;
    omp_set_dynamic(0);
    omp_set_num_threads(4);
  
    #pragma omp parallel shared(n)
    {
       #pragma omp single
       printf ("fib(%d) = %d\n", n, fib(n));
    }
  }
  </code></pre>
  
  <p>But when I check the value of <code>n</code> by debugging, I notice that apparently the recursive functions are still being called even when the condition <code>n &lt;= THRESHOLD</code> is true. So, my question is, am I misunderstanding something or the there's something wrong with the code?</p>