Skip to content
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

Unimplemented builtin __builtin_fpclassify #824

Open
VorpalBlade opened this issue Feb 13, 2023 · 1 comment
Open

Unimplemented builtin __builtin_fpclassify #824

VorpalBlade opened this issue Feb 13, 2023 · 1 comment
Labels
bug Something isn't working

Comments

@VorpalBlade
Copy link

VorpalBlade commented Feb 13, 2023

Trying to convert some code using fpclassify (from C99) yields: Unimplemented builtin __builtin_fpclassify.

Simple example that reproduces this

#include <math.h>
#include <stdio.h>

int main(void) {
    printf("%d\n", fpclassify(1.2));
    return 0;
}

Note: I'm fooling around with this software out of hobby interest applying it to some of my own old code. I'm not trying to convert any actual useful code base.

Software versions:

  • Arch Linux (rolling release distro).
  • glibc 2.37-2
  • clang 15.0.7-1
  • rustc 1.67.1 (from rustup)
  • c2rust 0.17.0 (from cargo install)
@kkysen kkysen added the bug Something isn't working label Feb 18, 2023
@fw-immunant
Copy link
Contributor

fw-immunant commented May 23, 2023

I looked into this just now. We don't have handling for fpclassify, and this is blocked by lacking any way to refer to the C constants that it returns. FP categories are not present in the libc crate, so it isn't clear how we could refer to them in transpiled code in order to convert the result of the stdlib's f64::classify to them as the semantics of the surrounding C code would demand.

We might be able to convert calls to fpclassify naïvely, and also convert references to FP_INFINITE and friends to the corresponding Rust enum variants rather than the values they expand to in C, but this would break (likely very rare) code that relies on knowledge of the actual implementation-defined values of these macros (e.g. if (fpclassify(f) == 0) ...).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants