[Bug fortran/82978] New: [PDT] [F2003] Paramaterized Derived Type LEN parameters take the latest value per-kind
foreese at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Tue Nov 14 02:11:00 GMT 2017
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82978
Bug ID: 82978
Summary: [PDT] [F2003] Paramaterized Derived Type LEN
parameters take the latest value per-kind
Product: gcc
Version: 8.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: fortran
Assignee: unassigned at gcc dot gnu.org
Reporter: foreese at gcc dot gnu.org
Target Milestone: ---
Created attachment 42596
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=42596&action=edit
test case exhibiting strange PDT behavior
In the attached file I see what I believe is unusual behavior. I skimmed the
F03/F08 specs and by all accounts I could see, this behavior is unexpected.
To summarize/generalize the test file, with the following declarations:
> type :: pdt_t(k, l)
> integer, kind :: k
> integer, len :: l
> character(len=l) :: ch
> end type
>
> type(pdt_t(k, l1)) :: t1
> type(pdt_t(k, l2)) :: t2
> ...
> type(pdt_t(k, ln)) :: tn
Then I see that len(t1%ch) == len(t2%ch) == ... == len(tn%ch) == ln. That is to
say, every PDT variable gets ch with the last length defined for the same kind.
If different kinds are passed, then the lengths seem to differ fine.
Here is my output for the attached file:
$ gfortran --version
GNU Fortran (GCC) 8.0.0 20171107 (experimental)
[...]
$ gfortran pdtlens.f03
$ ./a.out
exp. len act. len
1 2
2 2
4 5
5 5
9 7
7 7
100 200
200 200
Am I just misinterpreting the Fortran spec, or is this a real bug?
More information about the Gcc-bugs
mailing list