public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/110826] New: Fortran array of derived type with a pointer to function with dimensional arguments
@ 2023-07-26 20:55 mysecmailboks at gmail dot com
  2024-03-08 10:14 ` [Bug fortran/110826] Fortran array of derived type with a pointer to function with dimensional arguments fails redi at gcc dot gnu.org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: mysecmailboks at gmail dot com @ 2023-07-26 20:55 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110826

            Bug ID: 110826
           Summary: Fortran array of derived type with a pointer to
                    function with dimensional arguments
           Product: gcc
           Version: 13.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: mysecmailboks at gmail dot com
  Target Milestone: ---

The following program fails at `func_array(1)%f => zero_state`:
```
program test_func_array
   implicit none

   type pp
     procedure(func_template), pointer, nopass :: f =>null()
   end type pp

   abstract interface
      function func_template(state) result(dstate)
        implicit none
        real, dimension(:,:), intent(in)                    :: state
        real, dimension(size(state,1), size(state,2)) :: dstate
      end function
   end interface

   type(pp) :: func_array(4)
   real, dimension(4,6) :: state

   func_array(1)%f => zero_state

   print*,func_array(1)%f(state)
contains

  function zero_state(state) result(dstate)
    implicit none
    real, dimension(:,:), intent(in)                    :: state
    real, dimension(size(state,1), size(state,2)) :: dstate

    dstate = 0.

  end function zero_state
end program test_func_array
```
I have tested with various `gfortran` compilers at https://godbolt.org/. The
error is roughly the same. Along the lines of:
```
f951: internal compiler error: spec_dimen_size(): Bad dimension
0x75ee87 gfc_internal_error(char const*, ...)
        ???:0
0x72a016 spec_dimen_size(gfc_array_spec*, int, __mpz_struct (*) [1])
        ???:0
0x7d4bcb gfc_expression_rank(gfc_expr*)
        ???:0
0x7de37b gfc_resolve_code(gfc_code*, gfc_namespace*)
        ???:0
0x7c7500 gfc_parse_file()
        ???:0
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.
ASM generation compiler returned: 1
f951: internal compiler error: spec_dimen_size(): Bad dimension
0x75ee87 gfc_internal_error(char const*, ...)
        ???:0
0x72a016 spec_dimen_size(gfc_array_spec*, int, __mpz_struct (*) [1])
        ???:0
0x7d4bcb gfc_expression_rank(gfc_expr*)
        ???:0
0x7de37b gfc_resolve_code(gfc_code*, gfc_namespace*)
        ???:0
0x7c7500 gfc_parse_file()
        ???:0
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.
Execution build compiler returned: 1
```

The same error is given even if the dimensional arguments are explicitly
defined (as opposed to using `size`).

The program works if func_array is a scalar:
```
   type(pp) :: func_array
   real, dimension(4,6) :: state

   func_array%f => zero_state

   print*,func_array%f(state)
```

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2024-03-15 21:11 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-26 20:55 [Bug fortran/110826] New: Fortran array of derived type with a pointer to function with dimensional arguments mysecmailboks at gmail dot com
2024-03-08 10:14 ` [Bug fortran/110826] Fortran array of derived type with a pointer to function with dimensional arguments fails redi at gcc dot gnu.org
2024-03-11 20:33 ` anlauf at gcc dot gnu.org
2024-03-11 21:21 ` anlauf at gcc dot gnu.org
2024-03-12 18:16 ` cvs-commit at gcc dot gnu.org
2024-03-15 21:08 ` cvs-commit at gcc dot gnu.org
2024-03-15 21:11 ` anlauf at gcc dot gnu.org

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).