Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
28435 Discussions

invalid attempt to assign into a pointer that is not associated

ojacquet
Novice
1,188 Views

Hello,

Can you have a look on the attached simplified program whose purpose is to highlight an abnormal behaviour when assigning one derived type to another, using the base type they have in common. If I make some change in the program, it becomes normal.

The different behaviours of the program can be reproduced thanks to the preprocessor options added in the program.


With no preprocessor option, the program ends abnormally with the runtime error : forrtl: severe (122): invalid attempt to assign into a pointer that is not associated:

~ > ifort -g -fpp -trace test_derived_type_assignment.f90
~ > ./a.out
before COPY_TYPE1_TO_TYPE2
forrtl: severe (122): invalid attempt to assign into a pointer that is not associated
Image PC Routine Line Source
a.out 0000000000406BC6 Unknown Unknown Unknown
a.out 0000000000403021 types_copy_mp_cop 136 test_derived_type_assignment.f90
a.out 000000000040324C MAIN__ 169 test_derived_type_assignment.f90
a.out 0000000000402AC2 Unknown Unknown Unknown
libc-2.27.so 00007F692F891B97 __libc_start_main Unknown Unknown
a.out 00000000004029AA Unknown Unknown Unknown


Adding assignment overloading makes the program normal:

~ > ifort -g -fpp -D__ASSIGN_OVERL__ -trace test_derived_type_assignment.f90
~ > ./a.out
before COPY_TYPE1_TO_TYPE2
after COPY_TYPE1_TO_TYPE2


Removing the allocatable component of the base type makes the program normal:

~ > ifort -g -fpp -D__REM_ALLOC_COMPO__ -trace test_derived_type_assignment.f90
~ > ./a.out
before COPY_TYPE1_TO_TYPE2
after COPY_TYPE1_TO_TYPE2


Removing the unused routine COPY_TYPE2_TO_TYPE1 from the module TYPES_COPY makes the program normal:

~ > ifort -g -fpp -D__REM_COPY_ROUT__ -trace test_derived_type_assignment.f90
~ > ./a.out
before COPY_TYPE1_TO_TYPE2
after COPY_TYPE1_TO_TYPE2


Merging the modules TYPES and TYPES_COPY makes the program normal:

~ > ifort -g -fpp -D__MODUL_MERGED__ -trace test_derived_type_assignment.f90
~ > ./a.out
before COPY_TYPE1_TO_TYPE2
after COPY_TYPE1_TO_TYPE2


Can you explain me what I'm doing wrong?

Best regards,
Olivier

 

0 Kudos
1 Solution
Steve_Lionel
Honored Contributor III
1,178 Views

Please try the current compiler and report what it does.

View solution in original post

0 Kudos
6 Replies
Steve_Lionel
Honored Contributor III
1,184 Views

I can't reproduce the error using the oneAPI (2021.1.2) compiler on Windows (I don't have Linux.) Which compiler version are you using?

 
0 Kudos
ojacquet
Novice
1,182 Views

I use version ifort (IFORT) 19.1.1.217 20200306 on Linux.

Olivier

0 Kudos
Steve_Lionel
Honored Contributor III
1,179 Views

Please try the current compiler and report what it does.

0 Kudos
ojacquet
Novice
1,135 Views

Sorry, but I don't have the last version... I cannot afford buying a new licence now...

If anybody can do the test and give the answer, it would be very nice !

Olivier

0 Kudos
mecej4
Honored Contributor III
1,125 Views

The current release of the compiler package (OneAPI) does not need a license fee to be paid or a license file to be installed. You may purchase a support contract if you wish. You may download the portions that you want, using these links.

0 Kudos
ojacquet
Novice
1,095 Views

Thank you very much for your suggestions !

I have installed the new version of the compiler for free (thanks to Intel too) and it works fine: the anomally has disappeared.

Olivier

0 Kudos
Reply