The following code (derived from alloc_comp_constructor_1.f90): ! { dg-do run } ! { dg-options "-fdump-tree-original" } ! Test constructors of derived type with allocatable components (PR 20541). ! ! Contributed by Erik Edelmann <[EMAIL PROTECTED]> ! and Paul Thomas <[EMAIL PROTECTED]> !
Program test_constructor implicit none type :: thytype integer(4) :: a(2,2) end type thytype type :: mytype integer(4), allocatable :: a(:, :) type(thytype), allocatable :: q(:) end type mytype type (mytype) :: x type (thytype) :: foo = thytype(reshape ([43, 100, 54, 76], [2,2])) integer :: y(0:1, -1:0) = reshape ([42, 99, 55, 77], [2,2]) x = mytype(y, [foo, foo]) if (.not.allocated(x%a) .or. .not.allocated(x%q)) call abort() print *, 'y bounds' print *, lbound(y) print *, ubound(y) print *, 'x%a bounds' print *, lbound(x%a) print *, ubound(x%a) end program test_constructor compiled with ifort or gfortran, it returns y bounds 0 -1 1 0 x%a bounds 0 -1 1 0 while compiled with g95, it returns y bounds 0 -1 1 0 x%a bounds 1 1 2 2 What is the "standard conforming" answer? Dominique -- Summary: array bounds of allocatable components of derived types? Product: gcc Version: 4.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: dominiq at lps dot ens dot fr GCC build triplet: 4.2.0 20061009 GCC target triplet: x86_64-unknown-linux-gnu http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29434