[Patch, Fortran, F08] PR 85537: Invalid memory reference at runtime when calling subroutine through procedure pointer

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

[Patch, Fortran, F08] PR 85537: Invalid memory reference at runtime when calling subroutine through procedure pointer

Janus Weil-3
Hi all,

the attached patch implements some missing constraints from Fortran
2008 concerning procedure pointer initialization (cf. the standard
quote in comment #18), thus fixing two accepts-invalid and
ICE-on-invalid problems.

It regtests cleanly on x86_64-linux-gnu. Ok for trunk?

Cheers,
Janus

pr85537.diff (4K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: [Patch, Fortran, F08] PR 85537: Invalid memory reference at runtime when calling subroutine through procedure pointer

Janus Weil-3
Hi Steve,

> > the attached patch implements some missing constraints from Fortran
> > 2008 concerning procedure pointer initialization (cf. the standard
> > quote in comment #18), thus fixing two accepts-invalid and
> > ICE-on-invalid problems.
> >
> > It regtests cleanly on x86_64-linux-gnu. Ok for trunk?
>
> Looks OK to me.  Just minor comment.  If there are numbered
> constraints in either F2008 or F2018 for each of the if()
> conditionals, can you add a comment.

I fully agree. Luckily the reference to F08:C1220 is already present
in gfc_check_assign_symbol (but unfortunately not visible in the
diff), and it applies in the same way to the one IF clause that is
already there as well as the two new ones I'm adding, which is why I'm
not putting in an additional reference.

Cheers,
Janus
Reply | Threaded
Open this post in threaded view
|

Re: [Patch, Fortran, F08] PR 85537: Invalid memory reference at runtime when calling subroutine through procedure pointer

Steve Kargl
In reply to this post by Janus Weil-3
On Wed, Mar 27, 2019 at 11:22:49PM +0100, Janus Weil wrote:

>
> > > the attached patch implements some missing constraints from Fortran
> > > 2008 concerning procedure pointer initialization (cf. the standard
> > > quote in comment #18), thus fixing two accepts-invalid and
> > > ICE-on-invalid problems.
> >
> > I do not think this is correct.
> >
> > F2008:
> >
> > # 12.2.2.4 Procedure pointers
> >
> > #  A procedure pointer is a procedure that has the EXTERNAL and POINTER
> > # attributes; it may be pointer associated with an external procedure, #
> > # an internal procedure, [...]
> >
> > So a procedure pointer can be associated with an internal procedure.
> >
> > Comment#18 from the PR does not quote anything that says that
> > a procedure pointer cannot be associated with an internal procedure.
>
> Absolutely, a procedure pointer can in principle be associated with an
> internal procedure, and my patch does not change that. What the patch
> rejects is the ('static' in the C sense) pointer initialization of a
> procedure pointer with an internal procedure, which is forbidden per
> F2008:C1220.
>
> procedure(..), pointer :: pp => internal_proc
>
> A normal pointer assignment is still allowed per F2008:C729:
>
> pp => internal_proc
>
> Hope you agree (and sorry for not being more verbose in my explanation
> in the first place).
>

Just to add to the confusion/clarification.  Janus's patch
is concerned with an initial-proc-target, which is has restriction
that do not apply to a proc-target.

--
Steve
Reply | Threaded
Open this post in threaded view
|

Re: [Patch, Fortran, F08] PR 85537: Invalid memory reference at runtime when calling subroutine through procedure pointer

Janus Weil-3
In reply to this post by Janus Weil-3
Am Mi., 27. März 2019 um 23:32 Uhr schrieb Thomas Koenig
<[hidden email]>:
>
> Am 27.03.19 um 22:54 schrieb Thomas Koenig:
> > I do not think this is correct.
>
> ... and I missed the point that this was specifically about
> initializations.
>
> So, OK from my side.  Thanks!

Great. Thanks for the reviews, everyone! Committed to trunk as r269980.

Cheers,
Janus