- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
i got an error with the XE17.1 compiler. The following code produces two different crashes in line 35 (coming from 68), dependend on the type of "vec" in "T_VECTOR". The code worked with the XE16.X compilers.
module M_T_VECTOR implicit none type :: T_VECTOR !forrtl: severe (408): fort: (7): Attempt to use pointer ASSIGN_SOURCE when it is not associated with a target real :: vec(1:3) = [0.0,0.0,0.0] !forrtl: severe (157): Program Exception - access violation ! doubleprecision :: vec(1:3) = [0.0,0.0,0.0] contains procedure :: assignTo generic :: assignment(=) => assignTo procedure ::add generic :: operator(+) => add end type T_VECTOR type, extends(T_VECTOR) :: T_VECTOR_EXT type(T_VECTOR), allocatable :: disp(:) class(T_VECTOR_EXT), pointer :: pt_a => null() class(T_VECTOR_EXT), pointer :: pt_b(:) => null() end type T_VECTOR_EXT !-------------------------------------------------------- contains elemental subroutine assignTo(assign_target, assign_source) class(T_VECTOR), intent(inout) :: assign_target class(T_VECTOR), intent(in ) :: assign_source ! Exception thrown here assign_target%vec = assign_source%vec end subroutine elemental function add(lhs, rhs) result(ergebnis) class(T_VECTOR), intent(in ) :: lhs, rhs type(T_VECTOR) :: ergebnis ergebnis%vec = lhs%vec + rhs%vec end function end module M_T_VECTOR !======================================================== program main use M_T_VECTOR implicit none type(T_VECTOR_EXT), target :: a,b(2) a%pt_b => b a%pt_a => a allocate(a%disp(2)) allocate(b(1)%disp(2)) allocate(b(2)%disp(2)) !This works a%pt_a%disp(1) = a%pt_a%disp(1) + a%pt_b(1)%disp(1) a%pt_a%disp(2) = a%pt_a%disp(2) + a%pt_b(1)%disp(2) !This crashes a%pt_a%disp(:) = a%pt_a%disp(:) + a%pt_b(1)%disp(:) end program
Greetings
Wolf
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Try adding ", target" to lines 6 and 21
Jim Dempsey
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks for your advice, but that gives me the compile-time error:
error #6516: This attribute specification is not valid for a component definition statement. [TARGET]
Wolf
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you for the concise test case. I reproduced the access violation for both data types noted in the test case and escalated this to Development (internal tracking id noted below).
I was unable to reproduce the noted "forrtl: severe (408): fort: (7)" failure on Linux and I do not have 17.0 update 1 available for Windows at the moment. This appears to be a regression with the latest 17.0 update 1. I confirmed as you noted the test case compiles/runs successful with previous 16.0 compilers, and I also found it runs successfully when using the initial 17.0 release (Version 17.0.0.109 Build 20160721) on both Linux and Windows. I will let you know if I learn about any source code work around for this defect.
(Internal tracking id: DPD200416395)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you,
it can be worked around with a loop.
Wolf
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Ok, thank you for sharing that.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Kevin D. (Intel) wrote:
.. I will let you know if I learn about any source code work around for this defect. ..
@Kevin D. (Intel),
You may want to run the following with your development and see if it helps any in terms of diagnosing the defect with compiler 17. I'm pressed for time to go into my observations of Intel Fortran and interpretations of the standard, but I've run into issues previously with coders in our team defining generic assignments with a polymorphic right-hand side and often it leads to ambiguities too. See the effect of changing the declaration of the second parameter in the assignTo procedure below.
module M_T_VECTOR implicit none type :: T_VECTOR real :: vec(1:3) = [0.0,0.0,0.0] contains procedure :: assignTo generic :: assignment(=) => assignTo procedure ::add generic :: operator(+) => add end type T_VECTOR type, extends(T_VECTOR) :: T_VECTOR_EXT type(T_VECTOR), allocatable :: disp(:) class(T_VECTOR_EXT), pointer :: pt_a => null() class(T_VECTOR_EXT), pointer :: pt_b(:) => null() end type T_VECTOR_EXT !-------------------------------------------------------- contains elemental subroutine assignTo(assign_target, assign_source) class(T_VECTOR), intent(inout) :: assign_target type(T_VECTOR), intent(in ) :: assign_source !<-- see change here ! Exception thrown here assign_target%vec = assign_source%vec end subroutine elemental function add(lhs, rhs) result(ergebnis) class(T_VECTOR), intent(in ) :: lhs, rhs type(T_VECTOR) :: ergebnis ergebnis%vec = lhs%vec + rhs%vec end function end module M_T_VECTOR
program main use M_T_VECTOR, only : T_VECTOR_EXT implicit none type(T_VECTOR_EXT), target :: a,b(2) a%pt_b => b a%pt_a => a allocate(a%disp(2)) allocate(b(1)%disp(2)) allocate(b(2)%disp(2)) b(1)%disp(1)%vec = 1.0 b(1)%disp(2)%vec = 2.0 a%pt_a%disp(:) = a%pt_a%disp(:) + a%pt_b(1)%disp(:) print *, "a%disp(1)%vec = ", a%disp(1)%vec, " (expected values are all 1.0)" print *, "a%disp(2)%vec = ", a%disp(2)%vec, " (expected values are all 2.0)" stop end program
Upon execution with compiler 17, update 1:
a%disp(1)%vec = 1.000000 1.000000 1.000000 (expected values are all 1.0) a%disp(2)%vec = 2.000000 2.000000 2.000000 (expected values are all 2.0)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you FortranFan. I shared your update with them. Yours produces unexpected results w/17.0 initial release and expected results w/17.0 update 1.
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page