<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/98982>98982</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[Flang] Array with allocatable attribute is dynamically created without allocate statement
</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 : 19.0.0(73447a3302541c343525570222b318e7f94f9402)/AArch64
```
Array with `allocatable` attribute is dynamically created without `allocate statement`.
This is an error checking program. The result value is true when the array is checked in the program with `allocated intrinsic function`.
Gfortran outputs a warning message (with `-Wall` option) and does not seem to dynamically create the array. (The result value of `allocated` intrinsic function is true.)
ifort appears to output a warning message and create the array dynamically. (The result value of `allocated` intrinsic function is false.)
It seems that Flang-new creates the array dynamically, but do we need to output a warning message? (The result value of `allocated` intrinsic function is true.)
The following are the test program, Flang-new, Gfortran and ifort compilation/execution result.
fe1nalc34_2.f95:
```fortran
module typ
type xxx
integer,allocatable :: ai(:)
end type xxx
end module typ
module mod
use typ
contains
subroutine modsub(aa,item)
type(xxx),intent(in) :: aa
integer,intent(in) :: item
integer :: error = 0
select case(item)
case(1)
if (allocated(aa%ai )) error = error+1
print *," +++ fe1nalc34-S-1 : NG +++ ",error
end select
end subroutine modsub
end module mod
program fe1nalc34
use typ
use mod
integer,allocatable :: ai(:)
type(xxx) :: aa
integer :: res
interface
function funi(item) result(ai)
integer,allocatable :: ai(:)
integer,intent(in) :: item
endfunction funi
end interface
call modsub(xxx(funi(2)),1)
end program fe1nalc34
function funi(item) result(ai)
integer,allocatable :: ai(:)
integer,intent(in) :: item
select case(item)
case(1)
return
end select
end function funi
```
```
$ flang-new fe1nalc34_2.f95; ./a.out
+++ fe1nalc34-S-1 : NG +++ 1
$
```
```
$ gfortran fe1nalc34_2.f95; ./a.out
fe1nalc34_2.f95:37:30:
37 | function funi(item) result(ai)
| 1
Warning: Unused variable ‘ai’ declared at (1) [-Wunused-variable]
fe1nalc34_2.f95:37:30:
37 | function funi(item) result(ai)
| 1
Warning: Return value ‘ai’ of function ‘funi’ declared at (1) not set [-Wreturn-type]
fe1nalc34_2.f95:26:17:
26 | type(xxx) :: aa
| 1
Warning: Unused variable ‘aa’ declared at (1) [-Wunused-variable]
fe1nalc34_2.f95:25:30:
25 | integer,allocatable :: ai(:)
| 1
Warning: Unused variable ‘ai’ declared at (1) [-Wunused-variable]
fe1nalc34_2.f95:27:16:
27 | integer :: res
| 1
Warning: Unused variable ‘res’ declared at (1) [-Wunused-variable]
+++ fe1nalc34-S-1 : NG +++ 0
$
```
```
$ ifort -diag-disable=10448 fe1nalc34_2.f90
fe1nalc34_22.f90(38): warning #6178: The return value of this FUNCTION has not been defined. [AI]
function funi(item) result(ai)
---------------------------^
+++ fe1nalc34-S-1 : NG +++ 1
$
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzMWE2TmzgQ_TXypcuUEGDg4IPHE6dyyVbtJpvjloDGKIsllyTm499vCYGNvybxZA9xTTEgUPd7_bpbAm6M2ErEJUkeSPI4451tlF6qRqp5_X1WqOp1SRZ0-KOPhK7-Rm2EkqBqqFsut3OJz0CiFYR5QANKWJZGcZzyKKIsicMyiqOEJUlKGWNFFGaY1nlc5zFlhOWEbVYrXTaL2Bs_8-WPK635KzwL2wBZUN62quSWFy2SBQVurRZFZxGEgepV8p0oedu-QqmRW6z6eaqzk6kIxnKLO5SWLGgA4N18aYRxRrgE1FppKBss_xVyC3uttprvAvjSIGg0XWvhibdd79PqDuG5QQm2QeA9VmH8ZKxA-PHBxDmL_gGrhTSihLqTpRVKTkH548daaau5BNXZfWcNcHjmWjpsOzSGbxEIy0bb82-8bV1s1L43x3LgsoJKoQGpLBjEHVh1JVpHCoEzeEFX1XAC3jm5xD9GJXCeBx7CMQC-3yPXxjn3TK4QcVDP0Uyh3kT2c8Bq3poTZP74yY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