The following is non-standard and the compiler should probably generate a warning/error with '-pedantic -std=f95' MODULE T1 TYPE init_type integer :: i=1 END TYPE init_type TYPE(init_type) :: x END MODULE T1 END
OK, it took me time to see what was missing here, but the g95 error message is rather clear: "Module variable 'x' at (1) with default components must have the SAVE attribute" Confirmed and marked as minor.
I didn't find anything requiring this in the standard, and it would seem weird, given that SAVE is implicit in several cases. See also note 4.27.
(In reply to comment #2) > I didn't find anything requiring this in the standard, and it would seem weird, > given that SAVE is implicit in several cases. See also note 4.27. 4.4 : 'Unlike explicit initialization, default initialization does not imply that the object has the SAVE attribute'
(In reply to comment #3) > 4.4 : 'Unlike explicit initialization, default initialization does not imply > that the object has the SAVE attribute' So? I still don't see why this is invalid. The error message FX quoted still doesn't make any more sense to me. What am I missing?
(In reply to comment #4) > doesn't make any more sense to me. What am I missing? a constraint in 11.3
I working on a patch for this.
Subject: Bug 20845 Author: kargl Date: Fri Feb 3 21:32:14 2006 New Revision: 110560 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=110560 Log: 2006-02-03 Steven G. Kargl <kargls@comcast> Paul Thomas <pault@gcc.gnu.org> PR fortran/20845 * resolve.c (resolve_symbol): Default initialization of derived type component reguires the SAVE attribute. 2006-02-02 Steven G. Kargl <kargls@comcast> PR fortran/24958 match.c (gfc_match_nullify): Free the list from head not tail. PR fortran/25072 * match.c (match_forall_header): Fix internal error caused by bogus gfc_epxr pointers. 2006-02-03 Steven G. Kargl <kargls@comcast.net> PR fortran/24958 * gfortran.dg/nullify_2.f90 PR fortran/20845 * gfortran.dg/char_result_11.f90: Add SAVE. * gfortran.dg/der_pointer_4.f90: Ditto. * gfortran.dg/used_dummy_types_5.f90 * gfortran.dg/default_initialization.f90: New test. Added: branches/gcc-4_1-branch/gcc/testsuite/gfortran.dg/default_initialization.f90 branches/gcc-4_1-branch/gcc/testsuite/gfortran.dg/nullify_2.f90 Modified: branches/gcc-4_1-branch/gcc/fortran/ChangeLog branches/gcc-4_1-branch/gcc/fortran/match.c branches/gcc-4_1-branch/gcc/fortran/resolve.c branches/gcc-4_1-branch/gcc/testsuite/ChangeLog branches/gcc-4_1-branch/gcc/testsuite/gfortran.dg/char_result_11.f90 branches/gcc-4_1-branch/gcc/testsuite/gfortran.dg/der_pointer_4.f90 branches/gcc-4_1-branch/gcc/testsuite/gfortran.dg/used_dummy_types_5.f90
Fixed in 4.1 and trunk