hidden text to trigger early load of fonts ПродукцияПродукцияПродукцияПродукция Các sản phẩmCác sản phẩmCác sản phẩmCác sản phẩm المنتجاتالمنتجاتالمنتجاتالمنتجات מוצריםמוצריםמוצריםמוצרים
Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

interoperable funciton resul

amgarching
Beginner
562 Views

Dear Participants,

I am not sure where to post bug reports.
I noticed some people do it here.

I started a comp.lang.fortran thread

http://groups.google.com/group/comp.lang.fortran/browse_frm/thread/6297957e666cddc3?hl=en#

and posted a message to comp-fortran-90 about the issues I experienced.
There is at least one opinion from an active compiler developer
(on comp-fortran-90) that this might be a compiler bug.

In short, Intel Fortran compiler versions

11.1 Build 20091130

and

12.1.0.233 Build 20110811

segfault when executing the code below.
Possible reason is insisting on specific compiler calling
conventions for functions with bind(c) attribute.

Alexei

======= main.f90 =========
program prog
use test, only: caller_2
implicit none

call caller_2()
end program prog

======== test.f90 =========
module test

use iso_c_binding
implicit none
private

!
! Short structs  with size matching that  of some integer  type may be
! passed/returned  in  registers. That  depends  on  the platform  ABI
! convention.   BIND(C)  on  the  type(t)  and  relevant  function
! interfaces requests the Fortran compiler to emulate the behaviour of
! (some) C compiler.
!
! http://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html
!
type, public, bind(c) :: t
   private
   integer(c_intptr_t) :: ptr
end type t

type(t) :: a, b

public :: id
public :: caller_2

contains

  function id(i) result(o) bind(c)
    ! id :: type(t) -> type(t), same as jd().
    implicit none
    type(t), intent(in), value :: i
    type(t) :: o

    o = i
  end function id

  subroutine caller_2()
    implicit none

    b = id(a)
  end subroutine caller_2

end module test
0 Kudos
4 Replies
Steven_L_Intel1
Employee
562 Views
This is a fine place for reporting issues. I can see at least one other thing going wrong here - I will look into it further and let you know.
0 Kudos
Steven_L_Intel1
Employee
562 Views
I've identified at least two problems. On Linux IA-32, as you say, the function return value for id is not being put in the register, though the Fortran caller seems to be picking it up from there.

On Windows IA-32, the function id is not picking up the argument from the proper place, but it is returning the value correctly (I think).

Windows x64 seems to be fine. I haven't had the chance to test Linux x64.

Issue ID is DPD200179339. Thanks for bringing this to our attention. I will update this thread with any progress information.
0 Kudos
amgarching
Beginner
562 Views
Thanks, x86_64 is where I encountered this problem.
0 Kudos
Steven_L_Intel1
Employee
562 Views
I expect this to be fixed in a release later this year.
0 Kudos
Reply