Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Beginner
5 Views

Change in behavior of derived-type component initialization expressions

The following program compiles and runs with Intel Visual Fortran versions 10.1 through 14.0:

PROGRAM TESTTYPE

   TYPE MYTYPE
      INTEGER :: I => 0
   END TYPE MYTYPE
   
   TYPE(MYTYPE) :: X
   
   WRITE(*,*) X%I
         
END PROGRAM TESTTYPE

However, in versions 15 & 16 it fails with the following message:

testtype.f90(4): error #6680: A constant is not permitted in this context.   [0]

      INTEGER :: I => 0
----------------------^
compilation aborted for testtype.f90 (code 1)

It is noted that replacing the '=>' operator with '=' in the initialization expression works in all versions of the compiler tested.

------------------------------------------------------------------------------------------------------

QUESTION: What is the reason for the change in behaviour?

------------------------------------------------------------------------------------------------------

The IVF documentation states:

Is an initialization expression, or for pointer components, => NULL( ).

If init-ex is specified, a double colon must appear in the component definition. The equals assignment symbol (=) can only be specified for nonpointer components.

The initialization expression is evaluated in the scoping unit of the type definition.

One reading of the highlighted clause is that '=' or '=>' could be used for non-pointer components but that '=' must not be used for pointer components.

Many thanks,

David.

 

 

 

 

 

0 Kudos
7 Replies
Highlighted
Employee
5 Views

I will research this changed

I will research this changed behavior David and let you know what I find.

0 Kudos
Highlighted
Valued Contributor III
5 Views

Surely the compiler is just

Surely the compiler is just identifying bugs in your code that it did not identify before. The new behavior is an improvement!

0 Kudos
Highlighted
Black Belt
5 Views

For what it is worth, the

For what it is worth, the text in the current standard makes it absolutely clear.

"If => appears in component-initialization, POINTER shall appear in the component-attr-spec list. If = appears in component-initialization, neither POINTER nor ALLOCATABLE shall appear in the component-attr-spec-list."

 

0 Kudos
Highlighted
Employee
5 Views

Development believes parsing

Development believes parsing was also cleaned up for incorrect uses (as others noted regarding the Fortran Standard) of “=>” for non-pointer initialization in conjunction with this earlier post and internal tracking id DPD200157846 which was fixed in the 15.0 release, so this is the reason for the change in behavior.

I notified our Documentation writers about clarifying the init-ex component description and the statement you cited to make the "=" and "=>" uses clearer in a future revision.

(Internal tracking id: DPD200376067)

0 Kudos
Highlighted
Beginner
5 Views

Thank you for looking into

Thank you for looking into this issue Kevin and thank you Ian H for pointing out relevant text in the standard ... the latter may be of assistance to the Intel documentation writers in their review of the init-ex component description.

Regards,
David.

0 Kudos
Highlighted
Employee
5 Views

You're welcome David. Yes, I

You're welcome David. Yes, I agree. I passed along IanH's earlier citation to the Doc writers. It was helpful and very clear.

0 Kudos
Highlighted
Valued Contributor III
5 Views

Quote:Kevin Davis (Intel)

Kevin Davis (Intel) wrote:

You're welcome David. Yes, I agree. I passed along IanH's earlier citation to the Doc writers. It was helpful and very clear.

Kevin,

Please see my Message #11 in another thread where documentation is being discussed:

https://software.intel.com/en-us/forums/intel-visual-fortran-compiler-for-windows/topic/592538#comme...

0 Kudos