[RFC] Double initialization of variables (PR 50410, RFC patch)
Steve Kargl
sgk@troutmask.apl.washington.edu
Tue Oct 18 15:32:00 GMT 2011
On Tue, Oct 18, 2011 at 05:24:07PM +0200, Tobias Burnus wrote:
> Hello all,
>
> which double intializations should gfortran allow?
>
> With the attached patch, one only allows double DATA initialization,
> however, that causes regressions as it disallows to combine assignment
> initialization followed by DATA initialization.
>
> In other words: It fails for the second dg-error in
> gfortran.dg/data_initialized.f90 as with the patch the case is always
> rejected.
>
> On the other hand, with the current version, one gets an ICE for:
>
> subroutine one()
> type t1
> integer g
> end type t1
> type(t1) :: u=t1(1)
> data u%g /2/ ! { dg-error "is already initialized and may thus
> not be in the DATA statement" }
> print *, u%g
> end
>
> Other compilers seem to support this - some print 1 and others print 2.
>
> What do you think? Is the current patch OK, which rejects this? Or
> should one one try harder to also allow this kind of double initialization.
You can get rid of the ICE with the patch I posted in the
audit trail.
http://gcc.gnu.org/ml/gcc-bugs/2011-10/msg01670.html
troutmask:sgk[210] cat jk.f90
type t1
integer g
end type t1
type(t1) :: u=t1(1)
data u%g /2/
print *, u%g
end
troutmask:sgk[211] gfc4x -o z jk.f90 && ./z
1
When I look at -fdump-tree-original, it is as if the data
statement was simply neglected.
--
Steve
More information about the Fortran
mailing list