Skip to content

C2Rust fails to translate __builtin_nans with “Unimplemented builtin __builtin_nans” #1800

@lynae99

Description

@lynae99

C2Rust fails when translating a C program that uses the compiler builtin __builtin_nans. The translation stops during main and reports that this builtin is unimplemented.
This appears to be an unsupported builtin handling issue for signaling NaN generation.
To Reproduce

#include <stdio.h>

int main(void) {
    double x = __builtin_nans("");

    printf("%f\n", x);
    return 0;
}

Run C2Rust translation on the file:

c2rust transpile test.rs

Observed Behavior
C2Rust fails during translation:

Transpiling test.c
error: Failed to translate main: Unimplemented builtin __builtin_nans
--> test.c:4:16

Expected Behavior
C2Rust should either translate __builtin_nans to an equivalent Rust representation, or emit a more graceful unsupported-feature diagnostic without failing the whole function translation unexpectedly.
Environment

  • c2rust version: v0.21.0
  • platform: Ubuntu 24.04
  • Rust: nightly-2022-08-08
  • Clang version: 17.0.6

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    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