Skip to content

fesetround() when called from Rust on Linux doesn't work correctly, but does on Windows, gcc, and clang. #118102

@sarchar

Description

@sarchar

I know this is C code, but I promise this is about Rust. I tried this C code using extern "C" rust calls:

void test()
{
    fesetround(FE_UPWARD);
    printf("Should be -4: %d\n", (int)rint((double)-4.4));
}

I expected to see this happen: Should be -4: -4

Instead, this happened: Should be -4: -5

Meta

I have built a repository at https://github.com/sarchar/fesetroundbug but generally, this behavior only exists in the Linux build. With clang, gcc, and windows Rust, the correct value is displayed.

Please help.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-discussionCategory: Discussion or questions that doesn't represent real issues.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions