[Patch, fortran] PR122290 - PDT - gfortan rejects real intrinsic in default initialization & generic binding
Harald Anlauf
anlauf@gmx.de
Wed Oct 22 19:40:14 GMT 2025
Am 22.10.25 um 17:40 schrieb Paul Richard Thomas:
> This patch turned out to be straightforward once the source of the
> problems were identified:
>
> The problem with type matching came about because the component
> initializers were given BT_UNKNOWN before reduction was done. This was
> cured by giving the untreated initializers the same type as the
> component.
>
> Matching the template component initializers must be done with
> gfc_match_expr to prevent the reduction in gfc_match_init_expr from
> rendering them unusable for the PDT instances or to avoid the errors
> resulting from parameterized expressions.
>
> Where necessary, initializer expressions must have the parameter
> values substituted.
>
> Finally, generic intrinsic ops attempt to add the same entities to
> interfaces for each PDT instance. Suppress this in the same way as for
> entities used in submodules.
>
> The new testcase is an expanded version of the reporter's to check
> that the correct procedures are selected, when the intrinsic operators
> are referenced.
>
> Regtests on FC42/x86_64. OK for mainline?
>
> Paul
Hi Paul,
this looks good at first sight.
I ran the new f951 under valgrind on the new testcase and hit
an invalid read:
==8558== Invalid read of size 8
==8558== at 0xB1EB36: get_kind(bt, gfc_expr*, char const*, int)
(simplify.cc:133)
==8558== by 0xB31558: gfc_simplify_real(gfc_expr*, gfc_expr*)
(simplify.cc:7547)
==8558== by 0xA6E149: do_simplify(gfc_intrinsic_sym*, gfc_expr*)
(intrinsic.cc:4895)
==8558== by 0xA7A49A: gfc_intrinsic_func_interface(gfc_expr*, int)
(intrinsic.cc:5298)
==8558== by 0xAEED5B: resolve_unknown_f(gfc_expr*) (resolve.cc:3106)
==8558== by 0xAEFCBE: resolve_function(gfc_expr*) (resolve.cc:3533)
==8558== by 0xAFAFE8: gfc_resolve_expr(gfc_expr*) (resolve.cc:8181)
==8558== by 0xB099C0: gfc_resolve_code(gfc_code*, gfc_namespace*)
(resolve.cc:13878)
==8558== by 0xB18EDB: resolve_codes(gfc_namespace*) (resolve.cc:19897)
==8558== by 0xB18FAC: gfc_resolve(gfc_namespace*) (resolve.cc:19932)
==8558== by 0xADC576: resolve_all_program_units(gfc_namespace*)
(parse.cc:7481)
==8558== by 0xADCD85: gfc_parse_file() (parse.cc:7741)
Maybe this can be traced back to a code path where a variable
is not suitably initialized`
Best,
Harald
More information about the Fortran
mailing list