Issue |
149332
|
Summary |
[flang] Failure at the reallocation of self-assignment
|
Labels |
flang:frontend
|
Assignees |
|
Reporter |
DanielCChen
|
Consider the following code:
```
PROGRAM main
INTEGER :: idx( 5 ) = (/ 1, 3, 5, 7, 9 /)
REAL, ALLOCATABLE :: realArrayAlloc( :,: )
ALLOCATE(realArrayAlloc( 10,10 ), SOURCE=RESHAPE(&
(/ ((REAL( (REAL( j ) + (REAL( i ) / 100)) ),&
j = 1, 10), i = 1, 10) /), (/ 10,10 /)))
PRINT *, "Before: realArrayAlloc( 1:5,1:5 )"
PRINT 10, realArrayAlloc( 1:5,1:5 )
10 FORMAT(5(F5.2,", "))
PRINT *
PRINT *, "Before: realArrayAlloc"
PRINT 20, realArrayAlloc
20 FORMAT(10(F5.2,", "))
realArrayAlloc(& !!! realArrayAlloc should be deallocated and reallocated again here.
(/ (INT( realArrayAlloc( i,i ) ), i = 1, 9, 2) /),&
(/ (INT( realArrayAlloc( i,i ) ), i = 1, 9, 2) /) )&
= realArrayAlloc * 2.0
END PROGRAM main
```
At the line marked, the shape of the LHS is different from the RHS. Therefore, the LHS should be deallocated and reallocated again.
Flang failed at the execution as:
```
> a.out
Before: realArrayAlloc( 1:5,1:5 )
1.01, 2.01, 3.01, 4.01, 5.01,
1.02, 2.02, 3.02, 4.02, 5.02,
1.03, 2.03, 3.03, 4.03, 5.03,
1.04, 2.04, 3.04, 4.04, 5.04,
1.05, 2.05, 3.05, 4.05, 5.05,
Before: realArrayAlloc
1.01, 2.01, 3.01, 4.01, 5.01, 6.01, 7.01, 8.01, 9.01, 10.01,
1.02, 2.02, 3.02, 4.02, 5.02, 6.02, 7.02, 8.02, 9.02, 10.02,
1.03, 2.03, 3.03, 4.03, 5.03, 6.03, 7.03, 8.03, 9.03, 10.03,
1.04, 2.04, 3.04, 4.04, 5.04, 6.04, 7.04, 8.04, 9.04, 10.04,
1.05, 2.05, 3.05, 4.05, 5.05, 6.05, 7.05, 8.05, 9.05, 10.05,
1.06, 2.06, 3.06, 4.06, 5.06, 6.06, 7.06, 8.06, 9.06, 10.06,
1.07, 2.07, 3.07, 4.07, 5.07, 6.07, 7.07, 8.07, 9.07, 10.07,
1.08, 2.08, 3.08, 4.08, 5.08, 6.08, 7.08, 8.08, 9.08, 10.08,
1.09, 2.09, 3.09, 4.09, 5.09, 6.09, 7.09, 8.09, 9.09, 10.09,
1.10, 2.10, 3.10, 4.10, 5.10, 6.10, 7.10, 8.10, 9.10, 10.10,
fatal Fortran runtime error(t.f:21): temporary-stack: out of bounds access
IOT/Abort trap(coredump)
```
All ifort, gfortran and XLF execute the code successfully.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs