Quantcast
Channel: Recent posts
Viewing all articles
Browse latest Browse all 415

Impossible to see the contents of polymorphic variables in debugger

$
0
0

Good afternoon,

I have discovered that the debugger in Visual Studio is unable to display the contents of a polymorphic variable beyond its declared type. In the following example, I define a MAIN root type and extends it in three different manners. The LIST array contains the three examples. When I set a breakpoint at the line of the DO statement, and I try viewing the contents of LIST with the debugger, I can only see the contents of the root type. Same thing if I set a breakpoint in a code line following the ASSOCIATE statement: I cannot go beyond the variable defined in the root type. Is there any way to see the full contents of a polymorphic variable? I am testing the Intel Fortran 2018 beta using Visual Studio 2013.

Thanks in advance,

Jean 

    program derived_type

    type main
        character(10) type
    end type
    type,extends(main):: char_type
        character(10) a
    end type
    type,extends(main)::double_type
        double precision t
    end type
    type,extends(main)::array_type
        real,allocatable::x(:)
    end type
    type multi
        class(main),allocatable::var
    end type
    type (multi) list(3)
    list(1)%var=char_type('character','abcde')
    list(2)%var=double_type('double',4.4)
    list(3)%var=array_type('array',[1.,2.,3.])
    ! Put a breakpoint at the DO: impossible to see beyond the declared type, the dynamic portion is invisible
    do i=1,3
        associate(element=>list(i)%var)

            select type(element)
                ! Put a breakpoint on the associate name, also impossible to see beyond the declared type
            type is(char_type)
                print *,element%type,element%a
            type is(double_type)
                print *,element%type,element%t
            type is (array_type)
                print *,element%type,element%x
            end select
        end associate
    end do

    end program derived_type

 


Viewing all articles
Browse latest Browse all 415

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>