public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "federico.perini at gmail dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/109076] New: class extending abstract type with deferred procedures, with another unrelated procedure interface, crashes on valid code Date: Thu, 09 Mar 2023 07:36:36 +0000 [thread overview] Message-ID: <bug-109076-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109076 Bug ID: 109076 Summary: class extending abstract type with deferred procedures, with another unrelated procedure interface, crashes on valid code Product: gcc Version: 12.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran Assignee: unassigned at gcc dot gnu.org Reporter: federico.perini at gmail dot com Target Milestone: --- Hello gfortran/gcc team, I've reduced my issue to the following minimum viable example. Please note I haven't shortened the names because changing them sometimes solves this issue. - The abstract class has deferred procedures, with their abstract interface - The extended type implements them, AND it has another unrelated subroutine that contains a procedure interface - A casual solution is found by either shortening the unrelated subroutine name, or removing some imports from the abstract interface ==> With all gfortran versions from 12.2.0 down to 4.9, I get an "interface mismatch" issue: /app/example.f90:13:15: 13 | procedure :: expand => i_expand | 1 Error: Argument mismatch for the overriding procedure 'expand' at (1): Shape mismatch in argument 'array' The code can be found to play with here: https://godbolt.org/z/GfKGE1cYa And is also here: module my_mod use iso_fortran_env, only: real64 implicit none private type, abstract, public :: parallel_class contains procedure(par_expand_r64), pass(this), deferred :: expand end type parallel_class type, public, extends(parallel_class) :: interpolator contains procedure :: expand => i_expand end type interpolator abstract interface pure subroutine par_expand_r64(this,array) import parallel_class,real64 class(parallel_class), intent(inout) :: this real(real64), intent(in) :: array(:) end subroutine par_expand_r64 pure function interp_fun(ndim,x) result(fun_values) ! ****** SOLUTION #1 ******* !import real64 ! works with this import real64,interpolator ! this crashes gfortran-12 integer , intent(in) :: ndim real(real64) , intent(in) :: x real(real64) , dimension(ndim) :: fun_values end function interp_fun end interface contains !****** SOLUTION #2 ****** !subroutine create_object(this,fun) ! works with this name subroutine interpolator_create_fromfun_fixedstep(this,fun) ! crashes with this name class(interpolator) , intent(inout) :: this procedure(interp_fun) :: fun print *, 'hello world' end subroutine ! Get comm size pure subroutine i_expand(this,array) class(interpolator), intent(inout) :: this real(real64), intent(in) :: array(:) end subroutine i_expand end module my_mod Thank you, Federico
next reply other threads:[~2023-03-09 7:36 UTC|newest] Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top 2023-03-09 7:36 federico.perini at gmail dot com [this message] 2023-03-10 4:15 ` [Bug fortran/109076] " jvdelisle at gcc dot gnu.org 2023-03-10 7:28 ` federico.perini at gmail dot com
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-109076-4@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: linkBe 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).