On Sun, Nov 30, 2008 at 5:28 AM, Steve Kargl <[EMAIL PROTECTED]> wrote: > First, I'll preface this with "I'm probably doing something wrong." > I'm adding support to gfortran for the ERRMSG argument to [DE]ALLOCATE. > Here's, some code to demonstrate: > > program a > call works > call fails > end program a > ! > ! Work with all optimization levels. > ! > subroutine works > character(len=70) :: err = 'No error' > integer, allocatable :: i(:) > allocate(i(4), errmsg=err) ! err is unchanged. > print *, err > deallocate(i) > allocate(i(4), i(5), errmsg=err) ! err is assigned an error message. > print *, err > end subroutine works > ! > ! Fails at -O[123] due to len=30, works with -O0. > ! > subroutine fails > character(len=30) :: err = 'No error' > integer, allocatable :: i(:) > allocate(i(4), errmsg=err) > print *, err > deallocate(i) > allocate(i(4), i(5), errmsg=err) > print *, err > end subroutine fails > > kargl[222] gfc4x -o z -fdump-tree-original a.f90 > kargl[223] ./z > No error > Attempt to deallocate an unallocated object > No error > Attempt to deallocate an unall > kargl[224] mv a.f90.003t.original abc > kargl[225] gfc4x -o z -fdump-tree-original -O a.f90 > a.f90: In function 'fails': > a.f90:16: error: non-trivial conversion at assignment > character(kind=1) * > character(kind=1)[1:30] > iftmp.17 = err; > > a.f90:16: error: non-trivial conversion at assignment > character(kind=1) * > character(kind=1)[1:30] > iftmp.20 = err; > > a.f90:16: internal compiler error: verify_gimple failed > Please submit a full bug report, > with preprocessed source if appropriate. > See <http://gcc.gnu.org/bugs.html> for instructions. > > Looking at a diff of the two -fdump-tree-original outputs shows: > > ERRMSG.12 = &"Attempt to deallocate an unallocated object"[1]{lb: 1 sz: > 1}; > - ERRMSG.12 = stat.11 != 0 ? (void) __builtin_memcpy ((void *) &err, (void > *) ERRMSG.12, 30) : (void) 0; > + ERRMSG.12 = stat.11 != 0 ? err = *(character(kind=1)[1:30] * {ref-all}) > ERRMSG.12 : (void) 0;
Btw, you assign "void" to ERRMSG.12 - this is certainly invalid GENERIC and not what you want to do, right? Richard.