<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/132603>132603</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[Flang][Question] compiling with -fstack-arrays option
</td>
</tr>
<tr>
<th>Labels</th>
<td>
flang
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
k-arrows
</td>
</tr>
</table>
<pre>
Consider the following program.
```f90
program test
real :: Q(8, 8)
integer :: i, j
do i = 1, 8
do j = 1, 8
Q(i, j) = i*j + i + j + 1
end do
end do
call qradd_Rdiag(Q, 1)
do i = 1, 8
print *, Q(:, i)
end do
contains
function matprod(Q, G) result(R)
real, intent(in) :: Q(:, :), G(:, :)
real :: R(size(Q, 1), size(G, 2))
R = 1.0
end function
subroutine qradd_Rdiag(Q, n)
integer(4), intent(in) :: n
real(4), intent(inout) :: Q(:, :)
integer(4) :: k
integer(4) :: m
real(4) :: G(2, 2)
m = int(size(Q, 2), kind(m))
do k = m - 1_4, n + 1_4, -1
Q(:, [k, k + 1_4]) = matprod(Q(:, [k, k + 1_4]), transpose(G))
end do
end subroutine qradd_Rdiag
end program
```
The execution result of the above program changes depending on whether -fstack-arrays is specified at compile time (reproducible on Godbolt).
https://godbolt.org/z/nbb8ebWxh
Am I using this option incorrectly?
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJyEVEFvqzgQ_jXOZZTIDKGBAwfSKNUeW620xycDA7gBm7VN-_p-_co2ybZ97W4UCXvGM_N9n8cjrJW9IipZdmTZaSMWN2hTXrbCGP1qN7Vu38p7raxsyYAbCDo9jvpVqh5mo3sjph3jFbvj8d8VnPFq9YAj67yXV4bECCytWFrBI8M8Z3gPOcOC8UoqRz2Zq1t613MMazVIYOkJknieVwAArYbn363-51Ov8ViEI5Jh9QwMjz4RHiGuEx9DqoVWM17dFoxXjRhH-NuItv3x1ErRM8wffcIkYv0W02ykcsCw8kYPw7PBe1-_-FxCKyeksnHXLapxUiuYhJuNbq8FHzwDQ3YZHcP8KabxMoasypHydqki0Zuwa9nwKdY8n4wfb-OJYW7lL_pAFO9htT34NQabj3yKzHd85XRFH7nYpTZ6cVLRVxKqm4TrjTPM92u1rwmpG-WvDurF_Sf5L0pdD1--9UwfS17NXkW8SREyT7G_Apj3AuKK9CKVv8zppl3snUsIm2ALyY99kCV2ZNxsk7Wf3tPJjpeQ8HYwO13b-0PT_E-ANzkjlJ21Xa-2-L07_fqbe7z51_f9_uFH558DAf2kZgkdHbsXdBcGh6j1C11DoRmE6slCSzOp1o8TreB1IDeQgW1nnWjCEBJvFqQFO1MjO0ktCAeNnmY5Ejg5ETDMDXkNlkbWI_k0D7qttX82hZ9Ng3OzDcqcGZ776Ntp0zM8_2J4VnWdU_3XzyFSqCb4AxbrEblBWtBz4CJVo42hxo1vLD1v2jJti7QQGyqTwx4PiHlabIay64oaOR7u0iQr6iLdJ5SIuzpJeNY0Iik2skSOGU8x5cWep8WuPhyatL1LijrFrhN7tuc0CTnuxvFl8jA30tqFyiTFO55uRlHTaMO4RuxGoXqG6Ce3KX3Atl56y_Z8lNbZf1M46cYw488hIjux7Pi4kA1PNzutinrOr9INn_WPEmwWM5afxJRuWOpdoyeGZ19s_Wxno5-pcQzPAbxleF7xv5T4TwAAAP__gyLXXw">