Skip to content

flang-new 19.0.0 bug: nan > 0, nan > 1 #89529

@zaikunzhang

Description

@zaikunzhang

Hi,

This is a bug of flang-new 19.0.0, when invoked with -Ofast (This is not recommended in general. I know).

Code (latest version available at https://github.com/zequipe/test_compiler/blob/master/test_flang_nan.f90):

! test_flang_nan
program test_flang_nan
use ieee_arithmetic, only : ieee_value, ieee_signaling_nan, ieee_quiet_nan
! The problem occurs with REAL64 and REAL32, not REAL16 or REAL128.
use iso_fortran_env, only : RP => REAL32 !REAL64

implicit none
real(RP) :: nan

nan = ieee_value(0.0_RP, ieee_signaling_nan)
! nan = ieee_value(0.0_RP, ieee_quiet_nan)  ! The same problem

print *, nan > 0, nan > 1, nan < 0, nan < 1

if (nan > 0 .or. nan > 1 .or. nan < 0 .or. nan < 1) then
    error stop 1
end if

end program test_flang_nan

Test:

uname -a && flang --version && flang -Ofast test_flang_nan.f90 && ./a.out

Result:

Linux 6.5.0-28-generic #29~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Thu Apr  4 14:39:20 UTC 2 x86_64 x86_64 x86_64 GNU/Linux
flang-new version 19.0.0git ([email protected]:llvm/llvm-project.git 37c175af955f0aeab67e8c553a0a47b2ed0fdba2)
Target: x86_64-unknown-linux-gnu
Thread model: posix
 T T F F
Fortran ERROR STOP: code 1

IEEE arithmetic exceptions signaled: INVALID

Thank you for taking a look.

Metadata

Metadata

Assignees

No one assigned

    Labels

    flangFlang issues not falling into any other categoryquestionA question, not bug report. Check out https://llvm.org/docs/GettingInvolved.html instead!

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions