- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The code below outputs a wrong value for List1(1)%Ptr%Val. This only happens, if the type (List) is used as an array.
If it is used as a single element, everything is fine. Unless I am missing something, I think this is a compiler bug.
Best regards,
Thomas
[plain]PROGRAM CLASSPTR TYPE :: BaseType REAL(8) :: val END TYPE TYPE :: List CLASS (BaseType), POINTER :: Ptr END TYPE TYPE (BaseType), TARGET :: Base1 CLASS (BaseType), POINTER :: BasePtr TYPE (List) :: List1(5) Base1%val = 34.123d0 List1(1)%Ptr => Base1 BasePtr => Base1 Write (*,*) BasePtr%Val, List1(1)%Ptr%Val END PROGRAM[/plain]
Link Copied
2 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Things get even worse when I copy the array into another one. The code below does result in an access violation upon the write (/assume:realloc_lhs is on) when compiled with Release option.
regards,
Thomas
[plain]PROGRAM CLASSPTR TYPE :: BaseType REAL(8) :: val END TYPE TYPE :: List CLASS (BaseType), POINTER :: Ptr END TYPE TYPE (BaseType), TARGET :: Base1 CLASS (BaseType), POINTER :: BasePtr TYPE (List), ALLOCATABLE :: List1(:), List2(:) Base1%val = 34.123d0 ALLOCATE(List1(1)) List1(1)%Ptr => Base1 List2 = List1 BasePtr => Base1 Write (*,*) BasePtr%Val, List1(1)%Ptr%Val, List2(1)%Ptr%Val END PROGRAM[/plain]
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks - we'll look into it.

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page