Consider the following test case: program defallocatable implicit none
! Demonstrate structure constructors with default initialization ! and allocatable arrays. (Unspecified in F2003, initialized to ! unallocated in F2008.) type mytype_t integer, allocatable :: data(:) end type type(mytype_t) :: my_object my_object = mytype_t () print *, 'allocated =', allocated (my_object%data) end program When compiling with gfortran, we get: $ gfortran defallocatable.f90 defallocatable.f90:14.25: my_object = mytype_t () 1 Error: No initializer for component 'data' given in the structure constructor at (1)! $ This may be a valid error in F2003. In F2003 section 4.5.9 paragraph 3, it states that "If a component with default initialization has no corresponding component-data-source, then the default initialization is applied to that component." But when a component is allocatable, it is not legal to specify a component-data-source. This creates a difference in how default initialization works with structure constructors, and other places where default initialization must take place. In F2008 the above paragraph, this time in section 4.5.10 paragraph 3, adds: "If an allocatable component has no corresponding component-data-source, then that component has an allocation status of unallocated." This closes the hole and makes default initialization of allocatable components in structure constructors work like it does everywhere else. So this enhancement request is to consider gfortran allow the code to compile under the F2008 semantics (which are seemingly undefined in F2003.) FWIW, g95 and ifort have the same problem. -- Summary: F2008: Default initialization, structure constructors, and allocatable components Product: gcc Version: 4.4.0 Status: UNCONFIRMED Severity: enhancement Priority: P3 Component: fortran AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: w6ws at earthlink dot net http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39988