Opened 6 years ago

Last modified 4 years ago

#47332 assigned defect

gcc46 @4.6.4_7 gfortran internal compiler error related to procedure pointers

Reported by: wyeast@… Owned by: macports-tickets@…
Priority: Normal Milestone:
Component: ports Version: 2.3.3
Keywords: Cc: larryv (Lawrence Velázquez)
Port: gcc46 gcc47 gcc48

Description

When compiling with gfortran I get an internal compiler error when compiling code that allocates a derived type that includes a function (procedure) pointer which returns an array. I see the same error with all of the following ports: gcc46 @4.6.4_7, gcc47 @4.7.4_3, and gcc48 @4.8.4_0. I am using a 10.6.8 Mac, but a coworker sees the same error with 10.9.5 (and gcc46 @4.6.4_7).

The same code compiles fine with the same versions of gfortran listed above on Ubuntu and Homebrew. Removing the array from being the return argument (e.g., making it an output argument) makes the error go away.

The specific error is:

decomp.F: In function 'decomp_register_method':
decomp.F:27:0: internal compiler error: in gfc_conv_descriptor_data_set, at fortran/trans-array.c:171
Please submit a full bug report,
with preprocessed source if appropriate.
See <https://trac.macports.org/newticket> for instructions.

A minimal piece of code that can reproduce the bug is:

module decomp

   implicit none

   abstract interface
      function decomp_function(input) result(output)
         integer, intent(in) :: input
         integer, dimension(:), pointer :: output
      end function
   end interface

   type decomp_list
      procedure (decomp_function), pointer, nopass :: decompFunc => null()
   end type decomp_list

   type (decomp_list), save, pointer :: decompositions => null()

   contains

   subroutine decomp_register_method(decompList, decompFunc)
      type (decomp_list), pointer :: decompList
      procedure (decomp_function), pointer :: decompFunc

      type (decomp_list), pointer :: decompCursor

      allocate(decompCursor )
      decompCursor % decompFunc => decompFunc

   end subroutine decomp_register_method

end module decomp

and can be compiled with "gfortran -ffree-form -c decomp.F" (assuming it's named decomp.F).

A diff that will allow the code to compile is:

@@ -4,9 +4,10 @@ module decomp
    implicit none

    abstract interface
-      function decomp_function(input) result(output)
+      function decomp_function(input, output) result(ierr)
          integer, intent(in) :: input
-         integer, dimension(:), pointer :: output
+         integer, dimension(:),  pointer :: output
+         integer :: ierr
       end function
    end interface

Change History (2)

comment:1 Changed 6 years ago by larryv (Lawrence Velázquez)

Cc: larryv@… added
Owner: changed from macports-tickets@… to mww@…

I can reproduce this on Yosemite (but not with GNU Fortran 4.8, oddly).

% port installed gcc4{5..9}
The following ports are currently installed:
  gcc45 @4.5.4_11+universal (active)
  gcc46 @4.6.4_7+universal (active)
  gcc47 @4.7.4_3+universal (active)
  gcc48 @4.8.4_0+universal (active)
  gcc49 @4.9.2_1+universal (active)
% gfortran-mp-4.5 -ffree-form -c decomp.F
decomp.F: In function 'decomp_register_method':
decomp.F:26:0: internal compiler error: in gfc_conv_descriptor_data_set, at fortran/trans-array.c:172
Please submit a full bug report,
with preprocessed source if appropriate.
See <https://trac.macports.org/newticket> for instructions.
% gfortran-mp-4.6 -ffree-form -c decomp.F
decomp.F: In function 'decomp_register_method':
decomp.F:26:0: internal compiler error: in gfc_conv_descriptor_data_set, at fortran/trans-array.c:171
Please submit a full bug report,
with preprocessed source if appropriate.
See <https://trac.macports.org/newticket> for instructions.
% gfortran-mp-4.7 -ffree-form -c decomp.F
decomp.F: In function 'decomp_register_method':
decomp.F:26:0: internal compiler error: in gfc_conv_descriptor_data_set, at fortran/trans-array.c:173
Please submit a full bug report,
with preprocessed source if appropriate.
See <https://trac.macports.org/newticket> for instructions.
% gfortran-mp-4.8 -ffree-form -c decomp.F
% gfortran-mp-4.9 -ffree-form -c decomp.F
%

comment:2 Changed 4 years ago by kurthindenburg (Kurt Hindenburg)

Owner: changed from mww@… to macports-tickets@…
Status: newassigned
Note: See TracTickets for help on using tickets.