https://gcc.gnu.org/bugzilla/show_bug.cgi?id=128806
Bug ID: 128806
Summary: Allocatable dummy corank mismatch not diagnosed with
polymorphic types
Product: gcc
Version: 17.0
Status: UNCONFIRMED
Keywords: accepts-invalid
Severity: normal
Priority: P3
Component: fortran
Assignee: unassigned at gcc dot gnu.org
Reporter: mikael at gcc dot gnu.org
Blocks: 83700
Target Milestone: ---
Testcase:
program prog
implicit none
integer, parameter :: n = 5
type :: t
integer :: c
end type
class(t), allocatable :: a[:]
integer :: i
allocate(a[5:*])
a%c = 7
call sub2(a)
contains
subroutine sub2(x)
class(t), allocatable, intent(in) :: x[:,:]
print *, lcobound(x)
print *, ucobound(x)
end subroutine
end program prog
This is accepted by the compiler, but should be rejected because of the corank
mismatch between the dummy X and the actual A.
F2023 (15.5.2.7: Allocatable dummy variables):
> The corank of the actual argument shall be the same as that of the dummy
> argument.
If the types are non-polymorphic, an error is correctly reported:
11 | call sub2(a)
| 1
Error: Corank mismatch in argument ‘x’ at (1) (2 and 1)
Referenced Bugs:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83700
[Bug 83700] [Meta-bug] Fortran Coarray issues