This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: array constructor


On Wed, Jul 06, 2005 at 06:18:02PM +0200, Salvatore Filippone wrote:
> What is going on here? 
>
> program test3
> 
>   implicit none
>   integer :: i
>   i = 9999
>   write(*,*) 'Test ',(/i,2,3,4,5,i/)
>   
> end program test3
> 
> [sfilippo@localhost TEMP]$ gfortran -o test3 test3.f90
> [sfilippo@localhost TEMP]$ ./test3 
>  Test   9999    2     3   4      5   1151552

Looks like you've found a bug.  Add -fdump-tree-original to your
command line.  You'll get a test3.f90.t0.original, which shows

    int4 A.1[6];
    struct array1_int4 atmp.0;

    atmp.0.dtype = 265;
    atmp.0.dim[0].stride = 1;
    atmp.0.dim[0].lbound = 0;
    atmp.0.dim[0].ubound = 5;
    atmp.0.data = (int4[0:] *) &A.1;
    atmp.0.offset = 0;
    (*atmp.0.data)[0] = i;
    {
      static int4 data.3[4] = {2, 3, 4, 5};

      __builtin_memcpy (&(*atmp.0.data)[1], &data.3, 16);
    }
    (*atmp.0.data)[17] = i;

Clearly, 17 should be 5.  If I had to guess, it looks like the 1 index
in the memcpy is added to the number of bytes 16 to get the next array
index.  Yep.  If I change to (/i,2,3,4,5,6,i).  The 17 becomes 21.

File a bug report.

-- 
Steve


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]