------- Comment #4 from burnus at gcc dot gnu dot org  2008-04-04 09:40 -------
I think the problem are related to nested FORALLs. The following is enough to  
           cause the valgrind error (add the needed definitions from comment
0). If I comment either the RDA(J1) assignment in the outer FORALL or the inner
FORALL, valgrind finds no error.

      FORALL (J1 = 1:10)
        RDA(J1) = RCA(J1) + 1.0_R1_KV
        FORALL (J2 = 1:9)
          IDA(J1,J2) = ICA(J1,J2) + 1
        END FORALL
      ENDFORALL

The line shown by valgrind is:
==629==    at 0x463A23: resolve_code (resolve.c:5902)

If I go to the source, this is:
      /* Record the current FORALL index.  */
      var_expr[nvar] = gfc_copy_expr (fa->var);

where of the function gfc_resolve_forall (i.e. the function has been inlined in
 resolve_code).

I have somehow the feeling that total_var is too small as for forall_save != 0
the size is not properly set. I think the problem is that it is that
forall_save has a nonzero value as soon as "RDA(J1) =" is encountered and thus
the size is not properly increased when the inner FORALL is encountered. If one
swaps the order of "RDA(J1) =" and the inner FOREACH loop, valgrind finds not
error.


-- 

burnus at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|internal compiler error with|internal compiler error with
                   |forall                      |nested FORALL


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35820

Reply via email to