This is the mail archive of the 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: [RFC] Double initialization of variables (PR 50410, RFC patch)

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.

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
troutmask:sgk[211] gfc4x -o z jk.f90 && ./z

When I look at -fdump-tree-original, it is as if the data
statement was simply neglected.


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