[Bug fortran/104750] New: Parameterized derived type extension from outside the host module
a.shahmoradi at gmail dot com
gcc-bugzilla@gcc.gnu.org
Wed Mar 2 07:09:32 GMT 2022
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104750
Bug ID: 104750
Summary: Parameterized derived type extension from outside the
host module
Product: gcc
Version: 10.3.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: fortran
Assignee: unassigned at gcc dot gnu.org
Reporter: a.shahmoradi at gmail dot com
Target Milestone: ---
Created attachment 52543
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=52543&action=edit
sample source code
The following code is standard-compliant but does not compile with gfortran 10,
11, or the latest GNU trunk.
```
module amat
type :: amatrix(k,c,r)
integer, kind :: k = 4
integer, len :: r = 1
integer, len :: c = 1
end type amatrix
end module
program test_PDT_extension
use amat
type, extends(amatrix) :: imatrix(key) ! valid
integer, kind :: key
integer(kind=k) :: m(c,r)
end type imatrix
end
```
It returns the error:
```
Error: Parameter 'k' at (1) has not been declared or is a variable, which does
not reduce to a constant expression
```
which is incorrect, because `k` is declared in the parent type.
This code compiles with ifort >2021 and possibly older versions. Attached is a
copy of the source code.
The code can be readily tested with all versions of GNU and Intel compilers
here: https://godbolt.org/z/xsz4Eb4qa
More information about the Gcc-bugs
mailing list