Hi,
I've found an apparent problem in 5.30 that wasn't there before (at least not in 5.10). If I declare a type containing an array (integers in my case) that used to declare a variable within a module, I appear to get two copies of the variable - one version for within the module, another when accessed outside the module.
The problem occurs if the array within the type has >= 256 entries - set it to 255 and it works as expected. It's only a problem in Win32 release and debug builds - it works as expected in checkmate and .NET builds.
The example below shows the problem - when run in win32 debug and I get different results depending on how I access tester%nchains. Also if you look at loc(tester) it's different inside and outside the TestMod module.
Any insight or a fix would be greatly appreciated.
Alan
! Demonstrates multiple instantiation of type within module
module TestMod
type TestType
integer:: nchains = 0
integer:: holes(256) ! we get two testers if array size >= 256
end type
type(TestType):: tester
contains
! Setup a test value in tester
subroutine SetupTest()
tester%nchains = 42
end subroutine SetupTest
! Return location of tester as seen by TestMod
integer function GetTest()
GetTest = tester%nchains
end function GetTest
end module TestMod
program Test
use TestMod
integer:: l1, l2
! Setup tester - nchains set to 42
call SetupTest()
! Get nchains from tester - can also comes LOC(tester)
l1 = GetTest() ! returns 42
l2 = tester%nchains ! returns 0 if holes array size >= 256
! Output the values - THEY DON'T MATCH IF HOLES ARRAY SIZE >= 256
print *, l1, l2
if (l1 /= l2) print *, 'testers are not the same !!'
end program