- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
(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
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks - we'll check it out.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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']) ---------------------^
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks Steve for the clarification.

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