public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/109076] New: class extending abstract type with deferred procedures, with another unrelated procedure interface, crashes on valid code
@ 2023-03-09 7:36 federico.perini at gmail dot com
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
0 siblings, 2 replies; 3+ messages in thread
From: federico.perini at gmail dot com @ 2023-03-09 7:36 UTC (permalink / raw)
To: gcc-bugs
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
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug fortran/109076] class extending abstract type with deferred procedures, with another unrelated procedure interface, crashes on valid code
2023-03-09 7:36 [Bug fortran/109076] New: class extending abstract type with deferred procedures, with another unrelated procedure interface, crashes on valid code federico.perini at gmail dot com
@ 2023-03-10 4:15 ` jvdelisle at gcc dot gnu.org
2023-03-10 7:28 ` federico.perini at gmail dot com
1 sibling, 0 replies; 3+ messages in thread
From: jvdelisle at gcc dot gnu.org @ 2023-03-10 4:15 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109076
Jerry DeLisle <jvdelisle at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jvdelisle at gcc dot gnu.org
--- Comment #1 from Jerry DeLisle <jvdelisle at gcc dot gnu.org> ---
In the summary statement you are saying crashes. Not sure what you mean. With
gfortran latest truck, aka 13, I get the following:
$ gfc pr109076.f90
pr109076.f90:13:15:
13 | procedure :: expand => i_expand
| 1
Error: Argument mismatch for the overriding procedure ‘expand’ at (1): Shape
mismatch in argument 'array'
pr109076.f90:11:57:
11 | type, public, extends(parallel_class) :: interpolator
| 1
Error: Derived-type ‘interpolator’ declared at (1) must be ABSTRACT because
‘expand’ is DEFERRED and not overridden
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug fortran/109076] class extending abstract type with deferred procedures, with another unrelated procedure interface, crashes on valid code
2023-03-09 7:36 [Bug fortran/109076] New: class extending abstract type with deferred procedures, with another unrelated procedure interface, crashes on valid code federico.perini at gmail dot com
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
1 sibling, 0 replies; 3+ messages in thread
From: federico.perini at gmail dot com @ 2023-03-10 7:28 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109076
--- Comment #2 from federico <federico.perini at gmail dot com> ---
Sorry I meant it does not compile what I think is valid code:
subroutine i_expand matches the given abstract interface exactly, I can't find
a shape mismatch. I wound two ways that will make the error go away:
- remove `interpolator` from the import statement in the abstract interface
(was not being used)
- change the name of the subroutine to a shorter one, in a non-deterministic
way
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-03-10 7:28 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-09 7:36 [Bug fortran/109076] New: class extending abstract type with deferred procedures, with another unrelated procedure interface, crashes on valid code federico.perini at gmail dot com
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
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).