<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/77979>77979</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Runtime error in intrinsic "execute_command_line" when the "cmdstat" argument is missing
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
psteinfeld
</td>
</tr>
</table>
<pre>
When I call the intrinsic "execute_command_line" and do not pass an actual argument for "cmdstat", the program gets a fatal runtime error. Here's a program that shows the problem:
```
program bug
implicit none
integer :: exitstatvar, cmdstatvar
character(len=256) :: msg
character(len=:), allocatable :: command
command='notthere'
msg=''
exitstatvar = 216
cmdstatvar = 343
msg = ''
cmdstatvar = 3
call execute_command_line(command , wait=.false., exitstat=exitstatvar, cmdmsg=msg )
print *, "test 2"
print *, "cmdstat: ", cmdstatvar
print *, "exitstat: ", exitstatvar
print *, "msg: ", msg
end program bug
```
When I compile and execute this program, I get the output:
```
test 2
cmdstat: 3
exitstat: 216
msg:
[psteinfeld@ice4 install]$ sh: notthere: command not found
fatal Fortran runtime error(/local/home/psteinfeld/test/install/nocmdstat.f90:12): Execution error with system status code: -1
```
This does not happen when the `exitstat` or the `cmdmsg` argument is missing.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyMVV2vozgM_TXhxboVGGjLAw-d7aKd19VK-zhKwUBWIUGJuZ3596tQKMz9GA2qivJh-_j42EjvVWeISpF_Efk1khP31pWjZ1KmJd1EN9v8KP_tycBXqKXWwD2BMuyU8aoGgUjfqZ6YvtV2GKRpvmllSCCCNA00FoxlGKX3IA3ImiepQbpuGsgwtNYFD_XQeJYsEAX-MQcYne2cHKAj9iChlSw1uMmwGgjIOesOAH-RI4GncGG9z71k8L29-9XNTdMg0ouIryK-iGO8_OblanWbuscGAKhh1KpWDMYa2nYNU0cOgqf0AvRdcUD8Kl1AvOAPq9Wg7q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