<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/78089>78089</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[Flang] Segmentation fault on ISHFTC test (gfortran.dg/ishftc_optional_size_1.f90)
</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>
Here is the reproducer, which is reduced from https://github.com/gcc-mirror/gcc/blob/master/gcc/testsuite/gfortran.dg/ishftc_optional_size_1.f90.
```console
$ cat test.f90
module m
implicit none
contains
elemental function ishftc1_ref (i, shift, size_) result(r)
integer(1), intent(in) :: i
integer, intent(in) :: shift
integer(1), intent(in), optional :: size_
integer(1) :: r
r = ishftc (i, shift=shift, size=size_)
end
elemental function ishftc1_val (i, shift, size_) result(r)
integer(1), intent(in) :: i
integer, intent(in) :: shift
integer(1), value, optional :: size_
integer(1) :: r
r = ishftc (i, shift=shift, size=size_)
end
end module m
program p
use m
implicit none
integer :: shift = 1
integer(1) :: i1 = 127
integer(1) :: expect1
expect1 = -2_1
if (ishftc (i1, shift) /= expect1) stop 4
if (ishftc1_ref (i1, shift) /= expect1) stop 5
if (ishftc1_val (i1, shift) /= expect1) stop 6
end program p
```
I tested this on x86_64 as follows:
```console
$ flang-new test.f90
$ ./a.out
Segmentation fault
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzMVU-PqzYQ_zTmMgoyhiRw4LDdCL13fr1Hxgzg1tjINrvbfvrKhmx2022aHiq9KEqYYebnmZ_nD3dODhqxJvtfyP6U8MWPxta_77i15tUlren-qL-hRZAO_IhgcbamWwRawp7hdZRiDK8sBl0HvTUTjN7PjuRPhDWENYP049KmwkxBEGI3SWuNXQXCmlaZlrBm4s7jVevRebdIj0HTG-st12k3ENZIN_ZenM3spdFcnZ38E89Z2lc0JfRE6BM50PUrjHZG4aZlBQjuIQAH41U7mW5RCNMqAchpVlJID9rozVEY7bnUboPZDFHhhNpzBf2iRQgF1sCys8UeCCtlIMiNsvfxIURJWAUW3aI8YaUlrLqgAUjtcQj5l1nQs-eo0cFQ6uB3_QRm8yeQXzg_X6R7jmtMD58cNBey3yFiNv8AcTGyVwMLJD9tBN1wk58-cRTkjarNHXX3MPUvIcT_RP3_x_ujbL9wteAGAT8H06g7-NwZ6-9szWD5BPPlvMXd751LvLfVF4PM3h2_TEpmqxU73rfDtxmFz25qZFVGhB07X49aW3OlZ71VVsrsQ71UEMZWfnrHZRU4b2YovsK4dvtDGPuvMS5l-xDG4WOm4aZubuV9_H20-x7nHnbgR-nAaHgrD-dDAdxBb5Qyr3Fe_8v47BXXw07j680QDe9SwhqemmUr9R84xB6N3dnz0HafwZOuzrsqr3iCdXake5ZVZZknY83KDintOqyyqj3yI_ZlRVva5xQ72oo-kTWjrKBZVtAyy1ie7hk_tP2BZT3PhcgKUlCcuFSpUi9TauyQSOcWrI8lLatE8RaVi_uOsZgRYSysPlsH-127DI4UVEnn3RXBS6_ikmyix_4Ef88w0Pr9x7fm1-fIT7jRRzcXYVWyWFXf2ZwhlO1vN1vzGwofId2CjrAmJvdXAAAA__-IFEfa">