Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

Type casting regression in ifort2018 beta

Juergen_R_R
Valued Contributor I
317 Views

The following code segfaults because the explicit allocation in the type casting does not work any more with ifort2018 beta. I filed a bug report already. A workaround is given.

module event_base
  implicit none
  private
  public :: event_callback_t
  public :: event_callback_nop_t
  public :: eio_callback_t
  public :: dispatch

  type, abstract :: event_callback_t
     private
  end type event_callback_t

  type, extends (event_callback_t) :: event_callback_nop_t
     private
  end type event_callback_nop_t

  type, abstract :: generic_event_t
     real, dimension(:), allocatable :: sqme
  end type generic_event_t

  type :: eio_callback_t
     class(event_callback_t), allocatable :: callback
   contains
     procedure :: set_parameters => eio_callback_set_parameters  
  end type eio_callback_t

contains

  subroutine eio_callback_set_parameters (eio, callback, i)
    class(eio_callback_t), intent(inout) :: eio
    class(event_callback_t), intent(in) :: callback
    integer, intent(in) :: i
    allocate (eio%callback, source = callback)
  end subroutine eio_callback_set_parameters

  subroutine dispatch (eio, event_callback)
    type(eio_callback_t), intent(inout) :: eio
    class(event_callback_t), allocatable, intent(in) :: event_callback
    !!! Workaround:
    ! type(event_callback_nop_t) :: tmp
    if (allocated (event_callback)) then
       call eio%set_parameters (event_callback, 1)
    else
       call eio%set_parameters (event_callback_nop_t (), 0)
       ! call eio%set_parameters (tmp, 0)
    end if
  end subroutine dispatch

end module event_base

program main
  use event_base

  type(eio_callback_t) :: eio
  class(event_callback_t), allocatable :: foo
  call dispatch (eio, foo)

end program main

 

0 Kudos
8 Replies
Juergen_R_R
Valued Contributor I
317 Views

Internal report number is #02767138

0 Kudos
Kevin_D_Intel
Employee
317 Views

Thank you Juergen. I took ownership of the internal report too. I will triage this one next.

0 Kudos
FortranFan
Honored Contributor II
317 Views

Kevin D (Intel) wrote:

Thank you Juergen. I took ownership of the internal report too. I will triage this one next.

Another workaround can be:

         asc: associate( nop => event_callback_nop_t() )
            call eio%set_parameters(nop, 0)
         end associate asc

around line 44 of the code from the original post.

0 Kudos
Juergen_R_R
Valued Contributor I
317 Views

Thanks for this nice workaround as well. For the auto(de)allocation, yes, this might be related. Before ifort17 came out (where there are even more problems in our code), we had ifort16 in our test suite without flags and with the -standard-semantics flag (which includes the -assume realloc_lhs) and made workarounds for all issues using explicit auto-allocation. 

FortranFan wrote:

Quote:

Kevin D (Intel) wrote:

 

Thank you Juergen. I took ownership of the internal report too. I will triage this one next.

 

 

Kevin,

My hunch is this incident is somehow connected to this thread:

https://software.intel.com/en-us/forums/intel-visual-fortran-compiler-fo...

Is it possible to check if the fix for above has made to compiler 18.0 beta?  If not, will the fix be included in the official 18.0 release later this year?

By the way, another workaround can be:

         asc: associate( nop => event_callback_nop_t() )
            call eio%set_parameters(nop, 0)
         end associate asc

around line 44 of the code from the original post.

 

Thanks,

0 Kudos
FortranFan
Honored Contributor II
317 Views

Cool.

Re: the first part of the quoted text, I had posted it too hastily; I checked it out myself and concluded things were ok in 18.0 beta and therefore, I edited my comments but OP was too quick for me! :-)

0 Kudos
Kevin_D_Intel
Employee
317 Views

You mentioned the test case seg-faults but I’m seeing the same runtime error with 18.0 and earlier compilers as shown below. What am I missing?

$ ifort -g -traceback -standard-semantics u733019.f90
Intel(R) Fortran Intel(R) 64 Compiler for applications running on Intel(R) 64, Version 18.0 Beta Build 20170425
Copyright (C) 1985-2017 Intel Corporation.  All rights reserved.

 Intel(R) Fortran 18.0-1505
GNU ld version 2.23.52.0.1-16.el7 20130226

$ ./a.out
forrtl: severe (190): for allocate(source=), source needs to be allocated
Image              PC                Routine            Line        Source      
a.out              0000000000404A24  Unknown               Unknown  Unknown
a.out              0000000000402BB1  event_base_mp_eio          33  u733019_orig.f90
a.out              0000000000402F1B  event_base_mp_dis          45  u733019_orig.f90
a.out              0000000000402F43  MAIN__                     57  u733019_orig.f90
a.out              0000000000402AB2  Unknown               Unknown  Unknown
libc-2.17.so       00007F406B706AF5  __libc_start_main     Unknown  Unknown
a.out              00000000004029A9  Unknown               Unknown  Unknown

 

0 Kudos
Juergen_R_R
Valued Contributor I
317 Views

Sorry, Kevin, the runtime error is what I saw. 

0 Kudos
Kevin_D_Intel
Employee
317 Views

Ok, great. Thank you for confirming. I routed this to Development. This does not appear to be a regression with only 18.0. Thank you for your added time/effort to help isolate this one.

(Internal tracking id: CMPLRS-42659)

0 Kudos
Reply