Hi Daniel,

Daniel Carrera:
This is a simple patch that fixes PR 4755.

It's PR 49755 - the 9 is missing in the number ...

2011-07-22  Daniel Carrera <dcarr...@gmail.com>

    * trans.c (gfc__allocate_allocatable): [PR 4755] Do not fix
    and the reallocate a variable that is already allocated.

Instead of "[PR 4755]" use: <tab>PR <component>/<number>. Namely:

2011-07-22  Daniel Carrera <dcarr...@gmail.com>

    PR fortran/49755
    * trans.c (gfc__allocate_allocatable): [PR 4755] Do not free
    and the reallocate a variable that is already allocated.

Please also include the test case from the PR in the patch - with added "! { dg-do run }" and also containing "! PR fortran/49755".

However, the bug is not fully fixed. If you try the testcase in the bugreport, you will see that it still fails - the stat= is correctly set, but the array shape is wrong.

The problem is that the "a.dim" setting should be done after allocation in the inner loop - also the a.offset is misplaced. If possible, one should also move the "D.1585" into the inner "else" block, which would save one from using the following code in case the memory is already allocated:

                  D.1585 = a.data;
                  ...
              a.data = D.1585;

The promised dump, cf. testcase in the PR.

        a.dim[0].lbound = 1;
        a.dim[0].ubound = 5;
        a.dim[0].stride = 1;
        a.dim[1].lbound = 1;
        a.dim[1].ubound = 5;
        a.dim[1].stride = 5;
        overflow.4 = 0;
if ((logical(kind=4)) __builtin_expect ((integer(kind=8)) (overflow.4 != 0), 0))
            stat.3 = 5014;
        else
          {
              void * restrict D.1585;

if ((logical(kind=4)) __builtin_expect ((integer(kind=8)) (a.data != 0B), 0))
                {
                  D.1585 = a.data;
                  stat.3 = 5014;
                }
             else
               ....
              a.data = D.1585;
            }
          }
        a.offset = -6;
        if (stat.3 != 0) goto L.3;
        L.3:

Tobias

Reply via email to