[Patch, Fortran, F08] PR45290: pointer initialization

Tobias Burnus burnus@net-b.de
Tue Aug 17 07:46:00 GMT 2010


  On 08/16/2010 11:40 PM, Janus Weil wrote:
> I hope everything should work as advertised. Regtesting was successful
> on x86_64-unknown-linux-gnu (except for the continuing failure of
> array_memcpy_3.f90, cf. PR45266).
> Ok for trunk?

For pointer initialization there is a case where the changed SAVE 
behaviour in Fortran 2008 matters. So far I had the impression that 
there is no such case, but seemingly we have now one. (Actually, that's 
not quite true: it also occurs for coarrays where I seem to handle it 
explicitly.)

"A variable, common block, or procedure pointer declared in the scoping 
unit of a main program, module, or submodule implicitly has the SAVE 
attribute, which may be con
rmed by explicit speci
cation" (Fortran 
2008, 5.3.16 SAVE attribute)

Thus, I believe the following program is valid and should not be 
rejected. We have now two possibilities: (a) setting SAVE_IMPLICIT or 
(b) adding explicit check for pointer initialization.


module m
   integer, target  :: t1
   integer, pointer :: p1 => t1 ! valid, "t1" is implicitly SAVE
end module m


The following program ICEs (segfault) via
     by 0x573B54: gfc_create_module_variable (trans-decl.c:3597)
in
     at 0x57E731: gfc_conv_variable (trans-expr.c:593)


module m
   integer, target, save  :: t1
   integer, pointer :: p1 => t1
end module m

program main
   use m
end program main

And the following is invalid and gives an ICE:

module m
   integer, target, save  :: t1
   integer, pointer :: p1 => t1
   integer, pointer, save :: p2 => p2 ! invalid & ICE
   integer, pointer :: p3 => p1 ! ICE & invalid as "p1" is not a TARGET
end module m

Tobias



More information about the Fortran mailing list