Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

flang-new 19.0.0 bug: sum([Inf, 0.0]) = NaN, while Inf + 0.0 = Inf #89528

Open
zaikunzhang opened this issue Apr 21, 2024 · 0 comments
Open

flang-new 19.0.0 bug: sum([Inf, 0.0]) = NaN, while Inf + 0.0 = Inf #89528

zaikunzhang opened this issue Apr 21, 2024 · 0 comments
Labels
flang Flang issues not falling into any other category

Comments

@zaikunzhang
Copy link

zaikunzhang commented Apr 21, 2024

Hi,

This is a bug of flang-new 19.0.0.

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

! test_sum.f90
program test_sum
use ieee_arithmetic, only : ieee_value, ieee_positive_inf
! The problem occurs with REAL128, REAL64, and REAL32. sum is not implemented for REAL16 as of flang 19.0.0.                                                                                            
use iso_fortran_env, only : RP => REAL128 !REAL64 !REAL32 !REAL16

implicit none
real(RP) :: x(2), y, inf

inf = ieee_value(0.0_RP, ieee_positive_inf)
x = [inf, 0.0_RP]
y = sum(x)

print *, sum(x), x(1) + x(2)
print *, 'sum(x) is ', y

if (.not. y >= inf) then
    error stop 1
end if

end program test_sum

Test:

uname -a && flang --version && flang test_sum.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 (git@github.com:llvm/llvm-project.git 37c175af955f0aeab67e8c553a0a47b2ed0fdba2)
Target: x86_64-unknown-linux-gnu
Thread model: posix
 NaN Inf
 sum(x) is  NaN
Fortran ERROR STOP: code 1

IEEE arithmetic exceptions signaled: INVALID

Thank you for taking a look.

@EugeneZelenko EugeneZelenko added flang Flang issues not falling into any other category and removed new issue labels Apr 21, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
flang Flang issues not falling into any other category
Projects
None yet
Development

No branches or pull requests

2 participants