Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
公告
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.

Wrong ASSOCIATED behavior?

Daniel_Dopico
新分销商 I
1,800 次查看

This code compiles on Intel Fortran 2019, but according to the standard it should not.

PROGRAM isASSOCIATED
    IMPLICIT NONE
    
    TYPE PUNTO
	    INTEGER idpt
	    REAL(8),DIMENSION(3)::pt_loc
    END TYPE PUNTO

    TYPE VECTOR
	    INTEGER idpt
	    REAL(8),DIMENSION(3)::vc_loc
    END TYPE VECTOR

    TYPE(PUNTO),POINTER::pt
    TYPE(VECTOR),TARGET::vc

    IF(ASSOCIATED(pt,vc)) THEN
        PRINT *,"Pointer associated with target"
    ELSE
        PRINT *,"Pointer not associated with target"
    ENDIF
END PROGRAM isASSOCIATED

The output of the program is of course the message "Pointer not associated with target", but there is no way that the pointer can be associated with the target because they have different types.

The standard says about the ASSOCIATED(pointer,[target]) that the target must have the same type as the pointer, nevertheless the Intel fortran documentation doesn't mention it. Is this an extension of Intel for some reason?

0 项奖励
1 解答
Steve_Lionel
名誉分销商 III
1,800 次查看

It's just a failure to check the types - I very much doubt it is a deliberate extension. 

The standard doesn't say "the target must have the same type". What it says is:

TARGET (optional) shall be allowable as the data-target or proc-target in a pointer assignment statement (10.2.2) in which POINTER is data-pointer-object or proc-pointer-object.

Nonetheless, it is evident that the use here is not conforming, as if you add:

 pt => vc

the compiler complains:

error #6795: The target must be of the same type and kind type parameters as the pointer.   [PT]
    pt => vc
----^

Enabling standards checking doesn't complain about the ASSOCIATED. In other words, it's simply an omission, or a bug if you prefer. I suggest reporting this through the Online Service Portal.

P.S. It would be a favor if an Intel person would edit the title to say ASSOCIATED rather than ASSOCIATE, which is something entirely different.

在原帖中查看解决方案

0 项奖励
7 回复数
jimdempseyatthecove
名誉分销商 III
1,800 次查看

My read is for the pointers to be associated they must be of the same type .AND. both pointing to the same location.

For the pointers to .NOT. be associated, one or both may be null .OR. both non-null pointing elsewhere. As to if a compiler error is to be generated, I am not sure as to if this behavior is "undefined".

It would be interesting to know the behavior of two different type pointers, initialized with C_F_POINTER to the same location (or overlapping locations).

Jim Dempsey

0 项奖励
Steve_Lionel
名誉分销商 III
1,801 次查看

It's just a failure to check the types - I very much doubt it is a deliberate extension. 

The standard doesn't say "the target must have the same type". What it says is:

TARGET (optional) shall be allowable as the data-target or proc-target in a pointer assignment statement (10.2.2) in which POINTER is data-pointer-object or proc-pointer-object.

Nonetheless, it is evident that the use here is not conforming, as if you add:

 pt => vc

the compiler complains:

error #6795: The target must be of the same type and kind type parameters as the pointer.   [PT]
    pt => vc
----^

Enabling standards checking doesn't complain about the ASSOCIATED. In other words, it's simply an omission, or a bug if you prefer. I suggest reporting this through the Online Service Portal.

P.S. It would be a favor if an Intel person would edit the title to say ASSOCIATED rather than ASSOCIATE, which is something entirely different.

0 项奖励
Daniel_Dopico
新分销商 I
1,800 次查看

Thank you Steve. Sorry for the typo in the topic title: as you said the ASSOCIATE construct is something completely different.

For me it is a bug too, but since the Intel documentation is not complete on this, I had doubts that this could be done on purpose (nevertheless if i am right a green color should be used for any intended extensión and this is not the case).

It would be welcome if they correct the bug and the documentation. I paste the documentation on the target here:

target (Input; optional) Must be a pointer or target. If it is a pointer, the pointer association status must be defined.

I thik it should be advised that the target should be "pointable" by the pointer, as you said, otherwise a compiler error would be obtained.

0 项奖励
Daniel_Dopico
新分销商 I
1,800 次查看

I have just put a ticket on this.

Thanks.

0 项奖励
jimdempseyatthecove
名誉分销商 III
1,800 次查看

Steve, aren't pointers that cannot be associated by definition .NOT. associated?

Jim Dempsey

0 项奖励
Steve_Lionel
名誉分销商 III
1,800 次查看

Jim, I don't understand your question,. Any given pointer CAN be associated, with an allowed target. The issue here in ASSOCIATED is that the standard requires that TARGET be allowed as a pointer target for POINTER, which it isn't in this example. The proper behavior is a compile-time error similar to the one I show in #3. I could certainly modify the example to associate pt with something else.

0 项奖励
Ron_Green
主持人
1,788 次查看

This bug was fixed in PSXE 2020 Update 2, compiler 19.1.2


0 项奖励
回复