Consider the following program:
program main
integer, target :: foo ! var 1
integer, pointer :: bar => null() ! var 2
integer :: abc = 123 ! var 3
bar => foo
bar = huge(foo)
print *, 'Kind of integer: ', kind(abc)
print *, 'Target: ', foo, ' kind=', kind(foo)
print *, 'Pointer ', bar, ' kind=', kind(bar)
end program
All 'integer':
32 bit: If I compile with normally in 32 bit (e.g. ftn95 main.f90 /link), the output is as follows:
Kind of integer: 3
Target: 2147483647 kind= 3
Pointer 2147483647 kind= 3
As expected, variables 1,2,3 have kind 3 (integer*4).
64 bit: However, if I compile with /64, the output is:
Kind of integer: 3
Target: 9223372036854775807 kind= 4
Pointer 9223372036854775807 kind= 4
which means that target and pointer (vars 2,3) are implicitly converted to integer*8, as also can be seen by the huge() value being assigned. I consider this wrong behavior.
All 'integer*4':
32 bit: If I replace 'integer' in vars 1,2,3 with 'integer*4', 32 bit compiles just fine and produces the expected output (see above).
64 bit: However, the 64bit version won't even compile:
0009) print *, 'Kind of integer: ', kind(abc)
*** Internal compiler error - floating point exception
1 ERROR [main.F90] - Compilation failed.
Target 'integer*8', pointer 'integer':
32 bit: As expected, this combination fails in 32 bit:
0006) bar => foo
*** This pointer assignment would assign a pointer to the wrong kind of data
64 bit: In 64 bit, the code surprisingly (or not?) compiles fine and gives the same output as in the first case (i.e. it implicitly converts the pointer to an integer*8 pointer)
All 'integer*8':
This works fine in both 32 bit and 64 bit.
I assume this behavior of ftn95/64 is a bug and needs to be fixed.
The bad thing here is that if you only use plain 'integer' as data type you won't even notice that actually the code is broken (e.g. if you rely on integers having a specific size).
Best regards, André
Edit: I used FTN95 v8.10.0