http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51082

             Bug #: 51082
           Summary: Proc-pointer: Wrong result for a pointer to a
                    proc-pointer component
    Classification: Unclassified
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Keywords: wrong-code
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassig...@gcc.gnu.org
        ReportedBy: bur...@gcc.gnu.org
                CC: xarthisius...@gmail.com


The following program reported at #gfortran shall print twice "1.0" but with
gfortran, it just prints:

   1.00000000
At line 23 of file pp.f90 (unit = 6, file = 'stdout')
Internal Error: bad real kind


If one looks at the dump, one sees:

  p_list.process = ala1;
  p = &p_list;

with the call being:
      D.1841 = p_list.process (&C.1840);
      _gfortran_transfer_real_write (&dt_parm.0, &D.1841, 4);

      D.1844 = p->process (&C.1843);
      _gfortran_transfer_real_write (&dt_parm.1, D.1844, 4);

Notice in particular that for the second case, one has "D.1844" instead of
"&D.1844".


program ala
   implicit none

   type process_list
      procedure(process_interface), pointer, nopass :: process
      type(process_list), pointer :: next => null()
   end type process_list

   abstract interface
      real function process_interface(x)
         real, intent(in) :: x
      end function process_interface
   end interface

   type(process_list), target  :: p_list
   type(process_list), pointer :: p


   p_list%process => ala1
   p => p_list

   write(*,*) p_list%process(1.0)
   write(*,*) p%process(1.0)     !!!! fails with gfortran

   contains
      real function ala1(x)
         implicit none
         real, intent(in) :: x
         ala1 = x
      end function ala1
end program ala

Reply via email to