<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/72822>72822</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [Flang] execution error when a variable with an undefined value is specified as an argument to sizeof intrinsic function
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            flang:frontend
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          ohno-fj
      </td>
    </tr>
</table>

<pre>
    ```
Version of flang-new : 18.0.0(103811a27abcbcc6792c88dcdd30034e5cc8adc3)
```

When a variable with an undefined value is specified as an argument to `sizeof` intrinsic function, the program terminates abnormally at runtime.  
ifort also terminated abnormally at runtime, but gfortran terminated normally with the function returning 0.

The following are the test program, Flang-new, Gfortran and ifort compilation/execution result.

sngts008_.f90:
```fortran
program main
  call s()
 print *,'pass'
contains
  subroutine s(a)
 integer,dimension(:),optional::a
    if(sizeof(a)/=0) print *,'err'
 end subroutine s
end program main
```

```
$ flang-new sngts008_.f90; ./a.out
Segmentation fault (core dumped)
$
```

```
$ gfortran sngts008_.f90; ./a.out
 pass
$
```

```
$ ifort sngts008_.f90; ./a.out
forrtl: severe (174): SIGSEGV, segmentation fault occurred
Image              PC Routine            Line        Source
libc.so.6 00007FDDD5C42520  Unknown               Unknown  Unknown
a.out 00000000004041D4  Unknown               Unknown  Unknown
a.out 000000000040418D  Unknown               Unknown  Unknown
libc.so.6 00007FDDD5C29D90  Unknown               Unknown  Unknown
libc.so.6 00007FDDD5C29E40  __libc_start_main     Unknown  Unknown
a.out 00000000004040A5  Unknown               Unknown Unknown
$
```

</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJysVU9v47YT_TT0ZRCBoiRLOvjgtdfBAr_DD027PQYjaiRzS5EG_yTdfvqCkh0n2SyCtBUM2xpy3rw3M-Sg92o0RBtWfWLVfoUxHK3b2KOxN8O3VWf77xu25ucP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