Follow up to PR 43388. Currently, ALLOCATE (var(allocate-shape-spec-list), SOURCE=source-expr) works but ALLOCATE (var(allocate-shape-spec-list), SOURCE=array-source-expr) does not; in the latter case the array shape should be taken from the SOURCE -- this is a new Fortran 2008 feature.
Currently, it is rejected with: allocate(a, source=c) ! FAILS but is valid F2008 1 Error: Array specification required in ALLOCATE statement at (1) Test case: type t end type t type(t) :: a(:), b, c(:) allocatable :: a,b,c allocate(b,c(5)) allocate(a(5), source=b) ! OK allocate(a, source=c) ! FAILS but is valid F2008 end >From the standards. Fortran 2003 has: C628 (R628) An allocate-shape-spec-list shall appear if and only if the allocate-object is an array. C632 (R623) The source-expr shall be a scalar or have the same rank as allocate-object. While Fortran 2008 has: C633 (R631) If allocate-object is an array either allocate-shape-spec-list shall appear or source-expr shall appear and have the same rank as allocate-object. If allocate-object is scalar, allocate-shape-spec-list shall not appear. C638 (R626) Each allocate-object shall be type compatible (4.3.1.3) with source-expr. If SOURCE= appears, source-expr shall be a scalar or have the same rank as each allocate-object. -- Summary: [F2008] ALLOCATE with SOURCE and no array-spec Product: gcc Version: 4.6.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: burnus at gcc dot gnu dot org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44672