Can anyone explain this error?

Dominique Dhumieres dominiq@lps.ens.fr
Mon Dec 7 16:26:00 GMT 2009


Hi all,

The following code (extracted from gfortran.dg/bind_c_usage_10.f03)

module mod
 use iso_c_binding
 implicit none
contains
  integer(c_int) function func1() bind(c, name="myFunc1")
    real(c_float) :: func1ent
    func1 = -5
    return
  entry func1ent()
    func1ent = -55.0
  end function func1
end module mod

gives the following error when compiled with -fdefault-integer-8:

[macbook] f90/bug% gfc -c -fdefault-integer-8 bind_c_usage_10_red.f03
bind_c_usage_10_red.f03:7.31:

  integer(c_int) function func1() bind(c, name="myFunc1")
                               1
Error: FUNCTION result func1 can't be of type INTEGER(4) in FUNCTION func1 at (1)

or

[macbook] f90/bug% gfc -c -fdefault-real-8 bind_c_usage_10_red.f03
bind_c_usage_10_red.f03:8.29:

    real(c_float) :: func1ent
                             1
Error: ENTRY result func1ent can't be of type REAL(4) in FUNCTION func1 at (1)

when compiled with -fdefault-real-8. 
These errors disappear if I comment the entry line. 
Is this error expected? If yes, why? (don't answer that I should not use the 
-fdefault-*-8 optionsi, I know!-).

TIA

Dominique



More information about the Fortran mailing list