fortrangfortran32bit-64bit

Compilation failed when using gfortran flag default-real-8 and stdlib


I am trying to compile my program in 64 bits. I use gfortran and the option default-real-8 to compile :

-fdefault-real-8 Set the default real type to an 8 byte wide type.

I use the stdlib of Fortran

but got an error:

build\dependencies\stdlib\src\stdlib_specialfunctions_gamma.f90:1175:18:

 1175 |             res = l_gamma(n + 1, 1.0D0)
      |                  1
Error: There is no specific function for the generic 'l_gamma' at (1)

If I believe the error, the function containing this call is

impure elemental function l_factorial_iint64(n) result(res)
    integer(int64), intent(in) :: n

    [...]
    
    res = l_gamma(n + 1, 1.0D0)
end function

So n being int(8) and 1.0D0 being real(8), I think it should find this overload:

impure elemental function l_gamma_iint64dp(z, x) result(res)
    integer(int64), intent(in) :: z
    real(dp), intent(in) :: x

    [...]

end function

But apparently not. Pretty new to Fortran and the kind stuff, I guess I am missing something!


Solution

  • The assumption that

    1.0D0 being real(8)

    is false. 1.0D0 WILL be promoted from a REAL(8) to REAL(16) under default-real-8, the documentation is very clear:

    This option promotes the default width of DOUBLE PRECISION and double real constants like 1.d0 to 16 bytes if possible.

    Since the l_gamma has no overload on real(16), the compilation fails.