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

Bug with allocation of allocatable character variable

OP1
New Contributor III
597 Views

The subroutine below will crash when the LEN keyword refers directly to the array W. I am using IVF 11.1, maybe this has been corrected in later versions.

[fortran]SUBROUTINE ANOTHER_TEST IMPLICIT NONE TYPE T_F CHARACTER(LEN=:),ALLOCATABLE :: VAL END TYPE T_F TYPE(T_F),ALLOCATABLE :: F(:) INTEGER :: N = 2 INTEGER :: W(2) = [6,12] INTEGER :: I,W_TEMP ALLOCATE(F(N)) DO I=1,N W_TEMP = W(I) !ALLOCATE(CHARACTER(LEN=W(I)) :: F(I)%VAL) ! This doesn't work. ALLOCATE(CHARACTER(LEN=W_TEMP) :: F(I)%VAL) ! This is ok. END DO END SUBROUTINE ANOTHER_TEST[/fortran]
0 Kudos
3 Replies
Steven_L_Intel1
Employee
597 Views
You don't say what the "crash" is nor the options being used - I'm not sure if I'm seeing the same thing you are. I do see, with uninitialized variable checking, an error for a use of I uninitialized which seems inappropriate. Is that what you see? I reported that as issue DPD200181457.
0 Kudos
OP1
New Contributor III
597 Views
Steve,

I get the following error, in Debug mode:

forrtl: severe (408): fort (11): Subscript #1 of the array W has value 0 which is less than the lower bound of 1.

This is probably what you observed as well.

Olivier
0 Kudos
Steven_L_Intel1
Employee
597 Views
No, I didn't see that. But I can reproduce that too.
0 Kudos
Reply