| Issue |
178812
|
| Summary |
[Flang] When -fstack-arrays is specified, the dummy argument corresponding to an actual argument of a character array _expression_ results in abnormal behavior
|
| Labels |
flang
|
| Assignees |
|
| Reporter |
3776-u2
|
```
Version of flang : 23.0.0git (eb773961aac45593ce126ed258d82c3c3abbaa93)
Target: aarch64-unknown-linux-gnu
```
When sample.f90 is compiled with flang using the -fstack-arrays option, the execution results can be incorrect. Specifically, this issue seems to be reproducible when only the ss1 function is compiled with the -fstack-arrays option. This is believed to be caused by stack corruption, and the issue may not be reproducible depending on program modifications or the execution environment.
sample.f90
``` fortran
subroutine ss1(a)
character*(*) a(1)
character*1 t_s
call u(t_s() //'?'//a )
call u(t_s() //'?'//a )
end
subroutine u(a)
character*(*) a(1)
if (a(1)/='#?11111') then
print *,'fail'
endif
end
function t_s()
character*(*) t_s
t_s='#'
end
character*(5) a(1)
a='11111'
call ss1(a)
print*,'pass'
end
```
``` text
$ /work/groups/ssoft/compiler/llvm/aarch64/main-latest/bin/flang -fstack-arrays sample.f90
$ ./a.out
fail
pass
$ /work/groups/ssoft/compiler/llvm/aarch64/main-latest/bin/flang sample.f90
$ ./a.out
pass
$
$ ifx sample.f90
$ ./a.out
pass
$
```
We were unable to verify the behavior with gfortran due to an internal error.
``` text
$ gfortran sample.f90
sample.f90:4:23:
4 | call u(t_s() //'?'//a )
| 1
internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <https://bugs.rockylinux.org/> for instructions.
$
```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs