<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/132646>132646</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[Flang] Incorrect execution results of max0 intrinsic function for various arguments
</td>
</tr>
<tr>
<th>Labels</th>
<td>
flang
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
ohno-fj
</td>
</tr>
</table>
<pre>
```
Version of flang : 21.0.0(3e6f618e86f5fbad2c2d5802416ec3d3366a2837)/AArch64
```
As in the attached program, when `max0 intrinsic function` is given 1, 2, and 8 byte in addition to `default integer (4 byte)`, the results of the function are all `default integer (4 byte)`.
`max0` is written as `accept more argument types than specified.` by:
```
https://github.com/llvm/llvm-project/blob/main/flang/docs/Extensions.md
Extensions, deletions, and legacy features supported by default
- Specific intrinsics AMAX0, AMAX1, AMIN0, AMIN1, DMAX1, DMIN1, MAX0, MAX1, MIN0, and MIN1
accept more argument types than specified.
They are replaced by the related generics followed by conversions to the specified result types.
```
Therefore, this program is correct.
And it appears that flang does not support extended argument types.
I have confirmed similar results only for min0.
I haven't checked the other intrinsic functions.
The following are the test program, Flang, Gfortran and ifx compilation/execution result.
max0.f90:
```fortran
program main
print *,kind(max0(1_1,2_1))
print *,kind(max0(1_2,2_2))
print *,kind(max0(1_4,2_4))
print *,kind(max0(1_8,2_8))
print *,kind(min0(1_1,2_1))
print *,kind(min0(1_2,2_2))
print *,kind(min0(1_4,2_4))
print *,kind(min0(1_8,2_8))
end program main
```
```
$ flang max0.f90; ./a.out
4
4
4
4
4
4
4
4
$
```
```
$ gfortran max0.f90; ./a.out
1
2
4
8
1
2
4
8
$
```
```
$ ifx max0.f90; ./a.out
1
2
4
8
1
2
4
8
$
```
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJzMVkGPozgT_TXOpTTIMYTQhxyY6Y9Pfdi97Gi1t5WxC_CMsZFt0p1_v7KBTk92WpO-LYo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