[Patch, fortran] PR122766 - [PDT] gfortran fails to compile first example in F2018 standard
Jerry D
jvdelisle2@gmail.com
Fri Nov 21 20:07:55 GMT 2025
On 11/21/25 8:45 AM, Paul Richard Thomas wrote:
> Hi All,
>
> I have to confess that I had never spotted the two PDT examples in the
> F2018 standard. To my horror, they both fail.
>
> The second example involves finalizers of PDTs and is already caught by
> 104650. I am onto that one as well :-)
>
> A PDT typespec in a function declaration such as;
>
> CONTAINS
> TYPE(t(single)) FUNCTION real_to_t1(x)
> REAL(single) x
> real_to_t1%value = x
> END FUNCTION
>
> causes gfc_use_derived to emit, "Derived type ‘pdtt_4’ at (1) is being
> used before it is defined", whereas this;
>
> CONTAINS
> FUNCTION real_to_t1(x)
> TYPE(t(single)) real_to_t1
> REAL(single) x
> real_to_t1%value = x
> END FUNCTION
>
> compiled and ran successfully. The attached patch fixes this problem and
> is explained by the ChangeLog and the comment in the patch.
>
> Regtest OK on FC43/x86_64. OK for mainline?
>
> Paul
I did not see the patch attached, however I tested it off of bugzilla.
OK from my point of view.
Jerry
More information about the Fortran
mailing list