http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47051
Paul Thomas <pault at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |pault at gcc dot gnu.org --- Comment #6 from Paul Thomas <pault at gcc dot gnu.org> 2010-12-23 17:51:00 UTC --- (In reply to comment #4) > INTEGER, DIMENSION(:), ALLOCATABLE :: a,b,c,d > ALLOCATE(a(-1:1),b(1:3),c(2:3),d(3:6)) > b=0 > c=0 > d=0 > a=b > write(6,*) LBOUND(a), size(a) > a=c > write(6,*) LBOUND(a), size(a) > a=d > write(6,*) LBOUND(a), size(a) > END > > will give > > -1 3 > 2 2 > 3 4 > > Note that there are two work-around: > (1) compile with -fno-realloc-lhs, > (2) use a(:). extending this example slightly: INTEGER, DIMENSION(:), ALLOCATABLE :: a,b,c,d ALLOCATE(a(-1:1),b(1:3),c(2:3),d(3:6)) b=0 c=0 d=0 write(6,*) LBOUND(a), size(a), loc(a(lbound(a))) a=b write(6,*) LBOUND(a), size(a), loc(a(lbound(a))) a=c write(6,*) LBOUND(a), size(a), loc(a(lbound(a))) a=d write(6,*) LBOUND(a), size(a), loc(a(lbound(a))) END gives [...@localhost pr47051]# ifort --version ifort (IFORT) 11.1 20090630 Copyright (C) 1985-2009 Intel Corporation. All rights reserved. [...@localhost pr47051]# ifort -assume realloc-lhs pr47051a.f90 [...@localhost pr47051]# ./a.out -1 3 17346660 1 3 17346652 2 2 17346648 3 4 17346644 and for gfortran: -1 3 140736566840176 1 3 140736566840128 2 2 140736566840080 3 4 140736566840032 Thus the bounds are the same and it was this comparison that made me stop where I did. Worryingly, though, the array is being reallocated at each assignment. If you examine the code, the address should be the same for the first two lines, since the array sizes are the same. In summary, the reallocation should NOT occur and the setting of the bounds should be sorted out. Cheers Paul