I have a possible bug/bugs that occur with a module containing a 2D array, type conversion, interfaces and the /check compiler option. There is an example at the end of the email showing the various problems (there is more info in the code comments):
If the realVals declaration occurs after the ADT spec the compiler crashes with an access violation in make_new_variable. Actually this occurs even if /check is omitted.
In SetTestType() the use of an int function with a kind parameter on an int-cast 2D array index where an index is a variable(!) causes the compiler to issue 'operand incompatible with opcode' error - if an intermediate integer is used then the problem goes away, or if /check is omitted, or if the array has constant indices
In SetTestType2(), nint produces incorrect values with or without /check (although it's a different incorrect value).
Problems 2 & 3 disappear if their interfaces are removed.
Compiler version is 5.10 and I'm doing a Win32 build.
Alan
! Demonstrate comiler bug with 2D arrays in modules whit /check option and interface module TestMod
! Some values - if this goes after type def compiler crashes, even here the initialisation fails real:: realVals(10,10) = 42.55
type TestType integer*1:: intKind1 end TestType
!real:: realVals(10,10) = 42.55 ! causes a compiler crash if placed here (with or without init)
interface subroutine SetTestType(tt, idx) type(TestType), intent(in out):: tt integer, intent(in):: idx end subroutine SetTestType
subroutine SetTestType2(tt, idx)
type(TestType), intent(in out):: tt
integer, intent(in):: idx
end subroutine SetTestType2
end interface
contains
subroutine SetTestType(tt, idx) type(TestType), intent(in out):: tt integer, intent(in):: idx
tt%intKind1 = int(nint(realVals(idx,4)), 1) ! generates 'operand incompatible with opcode' when realVals is 2D array
! creating an intermediate integer*4 solves the problem
end subroutine SetTestType
subroutine SetTestType2(tt, idx) type(TestType), intent(in out):: tt integer, intent(in):: idx
tt%intKind1 = nint(realVals(idx,4), 1) ! this is 52 with /check, 0 without, should be 43 (okay if interface removed)
end subroutine SetTestType2
end module TestMod
winapp use TestMod type(TestType):: newtt
realVals = 42.59 ! init in module doesn't work
call SetTestType(newtt, 3) call SetTestType2(newtt, 4) end