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

ICE

OP1
New Contributor III
1,146 Views

(Posted twice as previous post didn't go through)

The following code triggers an ICE when using IVF XE 14.0.3.202 and compiling a Win32, Debug configuration. This does not happen with x64, Debug. I am not sure if this has been reported.

 

PROGRAM MAIN
IMPLICIT NONE
TYPE :: T
CHARACTER(LEN=:),ALLOCATABLE :: P(:)
END TYPE T
TYPE(T) :: NOT_OK = T(P=['1111111111111111111111111111111111110'])
TYPE(T) :: OK = T(P=['111111111111111111111111111111111111'])
END PROGRAM MAIN

0 Kudos
5 Replies
Steven_L_Intel1
Employee
1,146 Views

Thanks - we'll check it out.

0 Kudos
Steven_L_Intel1
Employee
1,146 Views

I can reproduce the ICE in 14.0.3, but it is fixed in the beta 15.0 compiler. The compiler now correctly reports:

U515684.f90(8): error #6273: In a constant expression, the only value that may c
orrespond to an allocatable component is a reference to NULL().
TYPE(T) :: NOT_OK = T(P=['1111111111111111111111111111111111110'])
-------------------------^
U515684.f90(10): error #6273: In a constant expression, the only value that may
correspond to an allocatable component is a reference to NULL().
TYPE(T) :: OK = T(P=['111111111111111111111111111111111111'])
---------------------^

 

0 Kudos
OP1
New Contributor III
1,146 Views

Steve,

Is this limit only valid for the declaration of the variable, and not for an executable statement? The slightly modified code below does not trigger the ICE, and the difference seems rather subtle. Is it still wrong?

PROGRAM MAIN

IMPLICIT NONE

TYPE :: T

CHARACTER(LEN=:),ALLOCATABLE :: P(:)

END TYPE T

TYPE(T) :: NOT_OK
TYPE(T) :: OK

NOT_OK = T(P=['1111111111111111111111111111111111110'])
OK = T(P=['111111111111111111111111111111111111'])

WRITE(*,*) NOT_OK%P
WRITE(*,*) OK%P

END PROGRAM MAIN

 

0 Kudos
Steven_L_Intel1
Employee
1,146 Views

No, that's fine. In the first program, you specified an initialization for the variables using a structure constructor. The standard doesn't allow you to have any value in an initialization/constant (the terminology changed in F2008) expression that corresponds to an ALLOCATABLE component other than NULL(). The wording in the standard is as follows:

7.1.12 Constant Expression

It is an expression in which each operation is intrinsic, and each primary is

(3) a structure constructor where each component-spec corresponding to
(a) an allocatable component is a reference to the intrinsic function NULL,
(b) a pointer component is an initialization target or a reference to the intrinsic function NULL, and
(c) any other component is a constant expression

In the executable part, that's an intrinsic assignment and the rules provide for automatic allocation of allocatable components.

0 Kudos
OP1
New Contributor III
1,146 Views

Thanks Steve for the clarification.

0 Kudos
Reply