https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87568

            Bug ID: 87568
           Summary: Gfortran compile fails with bogus error message.
           Product: gcc
           Version: 8.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: david.sagan at gmail dot com
  Target Milestone: ---

consider the following test program:

subroutine tao_show_this ()
implicit none

type b_struct
  integer, pointer :: good_user => null()
end type

type a_struct
  type (b_struct), allocatable :: value_ptr(:)
end type

type (a_struct) a

a = a_struct()
end subroutine


Compiling gives:

> gfortran -c test.f90
test.f90:4:13:

 type b_struct
             1
Error: The rank of the element in the structure constructor at (1) does not
match that of the component (0/1)

I believe this error message is bogus. Ifort will compile this code without
error. 

Note: This code will compile if modified in a number of ways:
1) Replace "value_ptr(:)" with "value_ptr" as the allocatable component of
a_struct.
2) Replace "integer, pointer :: good_user => null()" with "integer :: good_user
= 0" as the component of b_struct.
3) Replace "a = a_struct()" with "a = a_struct(null())".

Reply via email to