Skip to content

[AArch64][compiler-rt] floating point exception is not raised when comparing (long double)NAN by < operator #60141

New issue

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

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

Already on GitHub? Sign in to your account

Open
utsumi-fj opened this issue Jan 19, 2023 · 1 comment

Comments

@utsumi-fj
Copy link

utsumi-fj commented Jan 19, 2023

When investigating #59924, another issue was found. This occurs when compiling with --rtlib=compiler-rt.
The "invalid" floating point exception is not raised when comparing (long double)NAN by < operator as follows.

$ clang --version
clang version 16.0.0 (https://github.com/llvm/llvm-project.git 60b98979241151f8d6ec8af9ebc4da421f4a0258)
Target: aarch64-unknown-linux-gnu
Thread model: posix
InstalledDir: /work03/lang/llvm/llvm/main/bin
$ cat test.c
#include <stdio.h>
#include <math.h>
#include <fenv.h>

int main() {
#pragma STDC FENV_ACCESS ON

  long double nan128 = (long double)NAN;
  if (nan128 < 1.0)
    puts("test");

  if (fetestexcept(FE_INVALID))
    puts("FE_INVALID");

  return 0;
}
$ clang test.c -lm
$ ./a.out
FE_INVALID
$ clang test.c -lm --rtlib=compiler-rt
$ ./a.out
$

It is expected that "FE_INVALID" is printed.

@llvmbot
Copy link
Member

llvmbot commented Jan 19, 2023

@llvm/issue-subscribers-backend-aarch64

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants