Debugger unable to display array contained in derived type
Since months debugging has been a hell because of a bug in the Intel Compiler and/or debugger integration: basically most (but not all) arrays are displayed with the length 0 in the debugger, and their content cannot be shown. The bug happens with allocatable arrays, pointers or static arrays. Of course it makes debugging pretty impossible, and I have to use WRITE statements... For instance the debugger shows me this:
whereas the array ARR has the size 2!
I finally succeeded to reproduce the bug with a simple program:
TYPE(TypeBase) :: ObjectBase
TYPE(TypeExt) :: ObjectExt
WRITE(*,*) 'Set a breakpoint here => debugger shows ObjectBase%Arr with length 0!!!'
and the module M1 is:
TYPE, PUBLIC :: TypeBase
REAL :: Arr(2) = 0.0
PROCEDURE :: AFunction
TYPE, PUBLIC, EXTENDS(TypeBase) :: TypeExt
FUNCTION AFunction(this) RESULT(Res)
CLASS(TypeBase), INTENT(IN) :: this
TYPE(TypeBase) :: Res
As you can see it needs a tricky combination:
If you comment the declaration of the variable ObjectExt in the program, it works as expected (debugger displays correct length and content)
If the function AFunction is not type bound anymore, it works as expected
If AFunction is made a subroutine, it works as expected
If one removes the type extension, it works as expected
So it seems that using a combination of type-bound functions and type extension prevents the debugger to show the length and content of arrays contained in derived types. I tried to play with debugger options in Visual Studio, and also with compiler settings, without success.
I am using Visual Studio 2015. I had the problem with the VS 2015 Update 2, and now Update 3, and with both Intel Visual Fortran 2016 and 2017.