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 <eedelmann@gcc.gnu.org> ! and Paul Thomas <pault@gcc.gnu.org> ! 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
As per discussion on the fortran@ mailing list, the answer returned by gfortran and ifort (namely, that LBOUND(x%a) is the same as LBOUND(y)) is standard-conforming, and g95 is in error.
Thanks, Dominique, for provoking the discussion and to veryone else for the discussion and the resolution of the PR. Paul