segfault with finalized dummy args

segfault with finalized dummy args

Hello!

The following program seems to reveal a compiler problem with finalized optional, allocatable polymorphic, intent(out) dummy arguments in a subprogram, which let the executable exit with a segfault on procedure entry(?).

module m
    implicit none
 
    ! finalized derived type
    type :: derived_type
    contains
        final :: finalizer
    end type
 
contains
    ! derived type's final subroutine
    subroutine finalizer(this)
        type(derived_type), intent(inout) :: this
    end subroutine
end module
 
program p
    use m
    implicit none
 
    call do_something()    ! runtime segfault
    ! forrtl: severe (174): SIGSEGV, segmentation fault occurred
contains
 
    ! a subprogram which returns finalized derived type
    ! important: intent(out), allocatable, optional
    subroutine do_something(arg)
        type(derived_type), intent(out), allocatable, optional :: arg
    end subroutine
end program

Note: As far as I checked it, the arguments attributes must not be changed (allocatable to pointer etc.) for the program to exhibit the reported behaviour.

Best regards

Ferdinand

4 posts / 0 nouveau(x)
Dernière contribution
Reportez-vous à notre Notice d'optimisation pour plus d'informations sur les choix et l'optimisation des performances dans les produits logiciels Intel.

Which version of ifort are you using? How did you compile this?

-Zaak

Recent ifort (unix) version 14.0.1, no compiler flags:

$ ifort test.f90
$ ./a.out
forrtl: severe (174): SIGSEGV, segmentation fault occurred
Image              PC                Routine            Line        Source             
a.out              000000000046AEF9  Unknown               Unknown  Unknown
a.out              0000000000469870  Unknown               Unknown  Unknown
a.out              0000000000438E72  Unknown               Unknown  Unknown
a.out              000000000041F273  Unknown               Unknown  Unknown
a.out              00000000004041AB  Unknown               Unknown  Unknown
libpthread.so.0    00007F2C71C05CB0  Unknown               Unknown  Unknown
a.out              0000000000402CE4  Unknown               Unknown  Unknown
a.out              0000000000402C46  Unknown               Unknown  Unknown
libc.so.6          00007F2C7185776D  Unknown               Unknown  Unknown
a.out              0000000000402B19  Unknown               Unknown  Unknown

 

 

Assuming allocatable, optional and intent(out) ...without pointer...
are permitted together, the error (SIGSEGV) is doubly interesting since the final routine should only be called upon deallocate (implicit or explicit). The deallocate code should not have been generated.

Jim Dempsey

www.quickthreadprogramming.com

Connectez-vous pour laisser un commentaire.