Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Beginner

Debugger unable to display array contained in derived type

Hello,

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:

2016-09-09 09-27-40.png

whereas the array ARR has the size 2!

I finally succeeded to reproduce the bug with a simple program:

PROGRAM Console
  USE m1
  IMPLICIT NONE
  TYPE(TypeBase) :: ObjectBase
  TYPE(TypeExt)  :: ObjectExt
  WRITE(*,*) 'Set a breakpoint here => debugger shows ObjectBase%Arr with length 0!!!'
END PROGRAM

and the module M1 is:

MODULE M1
  IMPLICIT NONE
  PRIVATE
  TYPE, PUBLIC :: TypeBase
    REAL :: Arr(2) = 0.0
  CONTAINS
    PROCEDURE :: AFunction
  END TYPE
  TYPE, PUBLIC, EXTENDS(TypeBase) :: TypeExt
  END TYPE
CONTAINS
FUNCTION AFunction(this) RESULT(Res)
  CLASS(TypeBase), INTENT(IN) :: this
  TYPE(TypeBase)  :: Res
END FUNCTION
END MODULE 

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.

0 Kudos