Skip to content

[Flang] Incorrect execution results of max0 intrinsic function for various arguments #132646

@ohno-fj

Description

@ohno-fj
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:

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
$

Metadata

Metadata

Assignees

Labels

flang:frontendquestionA question, not bug report. Check out https://llvm.org/docs/GettingInvolved.html instead!

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions