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

Superclass Objects and Subclass Objects

Hello,

I have some difficulties to point from a Superclass to a Subclass Object. tElement is the Superclass and tBeam is the Subclass.

 

TYPE(tBeam),				ALLOCATABLE, TARGET	:: beams(:)
CLASS(tElement),			POINTER	:: element
CLASS(tElement),			POINTER	:: elements(:)

ALLOCATE(beams(1:10))

It works for a single Object...:

ALLOCATE(Element, SOURCE = beams(1), STAT = ierror)

... but for an array it seems to work because ierror is 0, but in Visual Studio he shows me "undefined pointer/array"

ALLOCATE(Elements, SOURCE = beams, STAT = ierror)

is this a Visual Studio Bug or am I doing something wrong?

 

MODULE mElement
	IMPLICIT NONE
	
	PRIVATE
	PUBLIC :: tElement
	
	TYPE :: tElement
		INTEGER(4) :: element_property = 1234
	END TYPE tElement
END MODULE mElement
	
MODULE mBeam
	USE mElement
	IMPLICIT NONE
	
	TYPE, EXTENDS(tElement) :: tBeam
		INTEGER(4) :: beam_property = 5678
	END TYPE tBeam
END MODULE mBeam
	
	
PROGRAM TEST
	USE mBeam
	USE mElement
	IMPLICIT NONE
	
	TYPE(tBeam),				ALLOCATABLE, TARGET	:: beams(:)
	CLASS(tElement),			POINTER	:: element
	CLASS(tElement),			POINTER	:: elements(:)
	INTEGER(4)							:: ierror
	INTEGER(4)							:: element_property, beam_property
	
	ALLOCATE(beams(1:10))
	ALLOCATE(Element, SOURCE = beams(1), STAT = ierror)
	IF (ierror .EQ. 0) &
		& element_property = Element%element_property
	
	ALLOCATE(Elements, SOURCE = beams, STAT = ierror)
	IF (ierror .EQ. 0) &
		& element_property = Elements(3)%element_property
END PROGRAM TEST

Edit.: I am using

Microsoft Visual Studio Professional 2015 Version 14.0.25431.01 Update 3

Intel(R) Visual Fortran Compiler 18.0.0.124 [IA-32]

0 Kudos
4 Replies
Highlighted
New Contributor III
12 Views

Hi Julian,

it would help to post your exact compiler version (PSXE 2018 update 1 e.g.) and your Visual Studio version (2015 update 3 e.g.) as well to solve your issue. From my gut feeling I would say it is just an issue of Intel's VS extension for the debugger. I've observed similar with derived type components at other places where hoover over or watch list insist on 'undefined pointer/ array' but it is defined. A simple print shows, that the compiler is working fine in that cases. Unfortunately, the Visual Studio integration is sometimes not complete.

It would help to improve the integration by filing this issue on OSC also.

Best regards, Johannes

0 Kudos
Highlighted
Valued Contributor III
12 Views

See this thread:

https://software.intel.com/en-us/forums/intel-visual-fortran-compiler-for-windows/topic/754028

What you're noticing is likely a limitation of Intel Fortran integration with Visual Studio in that the object shows up as "undefined pointer/array" in the debugger watch windows, etc.  Code likely executes consistently with the instructions you have provided.

0 Kudos
Highlighted
Beginner
12 Views

OK thank you for your help so far. So should I still file a bug report or is this covered by the similar problem?

0 Kudos
Highlighted
12 Views

This doesn't seem familiar.

Please file the report; that way it can be triaged by the actual people making (or having made?) the fix to determine if it's a duplicate or not.

Really, we do appreciate it!

                        Thanks --

                                           --Lorri

 

0 Kudos