using GNU Fortran 95 (GCC) 4.1.0 20051126 (prerelease) with '-g -pedantic -std=f95', I get a bad / no diagnostic for the following invalid code: TYPE T1 INTEGER :: I=7 END TYPE T1 TYPE(T1), SAVE, DIMENSION(4) :: D DATA (D(I),I=1,2) /T1(3),T1(3)/ IF (ANY(D%I.NE.(/3,3,7,7/))) write(6,*) "Never mind ..." END
We currently have an ICE on that one: ## gfortran ## foo.f90:0: internal compiler error: in gfc_assign_data_value, at fortran/data.c:252 ## g95 ## In file foo.f90:5 DATA (D(I),I=1,2) /T1(3),T1(3)/ 1 Error: Variable 'd' which has a default initialization cannot appear in a DATA statement at (1) ## Intel ## ## Portland ## PGF90-W-0164-Overlapping data initializations of d (foo.f90) 0 inform, 1 warnings, 0 severes, 0 fatal for MAIN ## Sun ## DATA (D(I),I=1,2) /T1(3),T1(3)/ ^ "foo.f90", Line = 5, Column = 7: ERROR: "D" must not be specified in a DATA statement. It is typed as derived type "T1", which is default initialized.
This is probably a duplicate of 24978.
Just one question (A patch is on the way) Is this legal? TYPE T1 INTEGER :: I END TYPE T1 TYPE(T1), SAVE, DIMENSION(4) :: D DATA (D(I),I=1,2) /T1(3),T1(3)/ END
> Is this legal? > > TYPE T1 > INTEGER :: I > END TYPE T1 > TYPE(T1), SAVE, DIMENSION(4) :: D > DATA (D(I),I=1,2) /T1(3),T1(3)/ I think it is. I didn't found anything which said otherwise and all compilers accepted it. The relavant part of the standard, which disallows it is (Fortran 2003): "explicit initialization (5.1) : Explicit initialization may be specified for objects of intrinsic or derived type in type declaration statements or DATA statements. An object of a derived type that specifies default initialization shall not appear in a DATA statement." (and 3 paragraphs above "5.1.1".)
(In reply to comment #4) > > Is this legal? > > I think it is. I didn't found anything which said otherwise and all compilers > accepted it. This is with regards to the code in comment #3. Whereas the following is meant with regards to the code in comment #0. > The relavant part of the standard, which disallows it is (Fortran 2003):
Still working on it!
this has become: Error: 'd' at (1) already is initialized at (2) test.f90:0: internal compiler error: Segmentation fault Please submit a full bug report,
This is OK now with the patch to 32432 committed today. Closing as duplicate. *** This bug has been marked as a duplicate of 32432 ***