public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "pault at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug fortran/93924] [OOP] ICE with procedure pointer
Date: Tue, 26 Jan 2021 15:17:22 +0000 [thread overview]
Message-ID: <bug-93924-4-P0f6UlPmtQ@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-93924-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93924
--- Comment #10 from Paul Thomas <pault at gcc dot gnu.org> ---
(In reply to Paul Thomas from comment #9)
> Created attachment 50057 [details]
> Patch that "fixes" all versions of the problem
>
> The attached patch has a fragment of my finalize on assignment patch in the
> second chunk. The changes are small and few so could be applied manually.
>
> Whatever is the legality or otherwise, this fixes all versions of the
> problem and regtests OK.
>
> Please do what you will with this. If it is still open in a few weeks time,
> I will take it. At the present, I have too many open PRs.
>
> Paul
Final remarks for the time being in comments below:
module cs
implicit none
private
public classStar_map_ifc
public apply, selector
integer, target :: integer_target
abstract interface
function classStar_map_ifc(x) result(y)
class(*), pointer :: y
class(*), target, intent(in) :: x
end function classStar_map_ifc
end interface
contains
function fun(x) result(y)
class(*), pointer :: y
class(*), target, intent(in) :: x
select type (x)
type is (integer)
integer_target = x ! One way of overcoming dangling target business
y => integer_target
class default
y => null()
end select
end function fun
function apply(f, x) result(y)
procedure(classStar_map_ifc) :: f
integer, intent(in) :: x
integer :: y
class(*), pointer :: p
y = 0 ! Get rid of 'y' undefined warning
p => f(x)
select type (p)
type is (integer)
y = p
end select
end function apply
function selector() result(f)
procedure(classStar_map_ifc), pointer :: f
f => fun
end function selector
end module cs
program classStar_map
use cs
implicit none
integer :: x, y
procedure(classStar_map_ifc), pointer :: f
x = 123654
f => selector() ! Fixed by second chunk in patch (suppresses
class assignment)
y = apply(f, x) ! Fixed by first chunk in patch (passing
procedure)
print *, x, y
end program classStar_map
next prev parent reply other threads:[~2021-01-26 15:17 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <bug-93924-4@http.gcc.gnu.org/bugzilla/>
2020-04-25 12:18 ` [Bug fortran/93924] ICE in gfc_class_len_get at trans_expr.c:231 with function returning a " tkoenig at gcc dot gnu.org
2020-04-25 15:59 ` dominiq at lps dot ens.fr
2021-01-26 7:16 ` mscfd at gmx dot net
2021-01-26 7:19 ` mscfd at gmx dot net
2021-01-26 8:21 ` tkoenig at gcc dot gnu.org
2021-01-26 8:23 ` tkoenig at gcc dot gnu.org
2021-01-26 9:02 ` [Bug fortran/93924] [OOP] segfault with function returning a CLASS(*) pointer mscfd at gmx dot net
2021-01-26 9:03 ` [Bug fortran/93924] [OOP] ICE with procedure pointer tkoenig at gcc dot gnu.org
2021-01-26 12:44 ` pault at gcc dot gnu.org
2021-01-26 15:17 ` pault at gcc dot gnu.org [this message]
2021-01-27 11:07 ` pault at gcc dot gnu.org
2021-01-27 11:34 ` cvs-commit at gcc dot gnu.org
2021-05-04 12:31 ` rguenth at gcc dot gnu.org
2021-08-28 19:57 ` cvs-commit at gcc dot gnu.org
2021-09-06 18:43 ` cvs-commit at gcc dot gnu.org
2021-09-06 18:47 ` anlauf at gcc dot gnu.org
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=bug-93924-4-P0f6UlPmtQ@http.gcc.gnu.org/bugzilla/ \
--to=gcc-bugzilla@gcc.gnu.org \
--cc=gcc-bugs@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).