- 新着としてマーク
- ブックマーク
- 購読
- ミュート
- RSS フィードを購読する
- ハイライト
- 印刷
- 不適切なコンテンツを報告
In the current compiler there are anomalies in which assignments are allowed in elemental functions when the ASSOCIATE construct is used. It seems some associated names take on host-associated status. Nesting ASSOCIATE constructs removes this status--even for actual host-associated selectors. In all cases using the selector directly instead of the associate-name inside the construct "does the right thing" even when the associate-name does not. See examples below. I haven't grok'd enough of the standard to know whether something that is "construct associated" keeps track of--or magically gains--"host association" status so my expectations below in the code may not be standard conforming.
Compiling with Intel Visual Fortran 11.1.065 [IA-32]...
[fortran]module M5 type :: option integer :: id = 0 integer :: form = 0 logical :: multi = .false. integer :: code end type option integer :: hosted = 0 contains elemental subroutine set (opt) type(option), intent(inout) :: opt associate (f => opt% form, r => opt% code, t=>hosted) associate (s => opt% code, u=>hosted) select case (f) case (0) !OK; assign without using associate-name opt% code = 5 ! EXPECTED as opt is not host associated case (1) !error #7617: This host associated object appears in a 'defining' context ! in a PURE procedure or in an internal procedure contained in a PURE procedure.r = 5 ! UNEXPECTED; should be same as case 0 case (2) !OK; assign through inner-most associate-name s = 5 ! removes host-associated status case (3) !error #7617: This host associated object appears in a 'defining' context ! in a PURE procedure or in an internal procedure contained in a PURE procedure. t = 5 ! EXPECTED; associate-name t is host associated case (4) !OK u = 5 ! UNEXPECTED; expect to be same as case 3 and 5 case (5) !error #7617: This host associated object appears in a 'defining' context ! in a PURE procedure or in an internal procedure contained in a PURE procedure. hosted = 5 ! EXPECTED; hosted is host associated end select end associate end associate end subroutine set subroutine foo() type(option) :: v(5) call set(v) end subroutine foo end module[/fortran]
1 解決策
コピーされたリンク
4 返答(返信)
- 新着としてマーク
- ブックマーク
- 購読
- ミュート
- RSS フィードを購読する
- ハイライト
- 印刷
- 不適切なコンテンツを報告
Bump. Just want to make sure this doesn't get overlooked because the compiler is definitely acting strange and inconsistently when combining associate and elemental procedures. The nested associate shows more weirdness but isn't required. The error that is forcing me to stop using associate in my code is at the first level.
- 新着としてマーク
- ブックマーク
- 購読
- ミュート
- RSS フィードを購読する
- ハイライト
- 印刷
- 不適切なコンテンツを報告
Escalated as issue DPD200157282. Thanks for the nice test case.
