Silverfrost Forums

Welcome to our forums

Apparent regression bug in 8.10

22 Feb 2017 9:18 #18869

Hi all,

First of all I would like to thank you for the new FTN95 release.

Unfortunately, one of our codes which is declaring a C_EXTERNAL function is not working properly since the update, what appears to be a regression bug introduced in FTN95 8.10 (happens in both 32 and 64 bit).

The following test code fails to compile:

program regression
    integer, parameter :: singI = selected_int_kind(9)
    integer(singI) :: y

    c_external foo 'foo'    (ref) : integer(singI) ! Explicit kind parameter -> Does not compile!
    !c_external foo 'foo'    (ref) : integer*4 ! Works
    !c_external foo 'foo'    (ref) : integer ! Works

    y = foo(2_singI)
    print *, y

end program

The error is:

[FTN95/x64 Ver. 8.10.0 Copyright (c) Silverfrost Ltd 1993-2017]

0005)     c_external foo 'foo'    (ref) : integer(singI)
*** Bad return type in C_EXTERNAL
0008)     y = foo(2_singI)
*** FOO is a SUBROUTINE so cannot be used as a FUNCTION
    2 ERRORS  [<REGRESSION> FTN95 v8.10.0]
*** Compilation failed

It seems like explicitly defined kinds do not work on C_EXTERNAL declarations properly. If you comment in the second or third declaration instead the code compiles just fine. As far as I can see, http://www.silverfrost.com/ftn95-help/mixlan/callingc_c__fromftn95.aspx doesn't explicitly rule out explicit kind parameters (in fact it uses integer*4 in one of the examples), so I would consider this a bug(?).

Thanks in advance for commenting on the issue. André

22 Feb 2017 10:16 #18871

Rather strangely this does not reflect a regression in the usual sense. Previously if you used anything other than INTEGER or INTEGER*x then you would get INTEGER anyway. In your case you wanted INTEGER so the result was correct but it would be incorrect for other INTEGER kinds.

Currently the compiler will accept INTEGER, INTEGER*x and INTEGER(7) but other kind values are not yet available in this context.

Please login to reply.