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

[BUG]: Current Universal CRT on windows compilers appears out of date #3572

Open
tjaurini opened this issue Apr 26, 2022 · 3 comments
Open
Labels

Comments

@tjaurini
Copy link

Describe the bug

The current Universal C runtime on the website seems to still have the "round away from zero" bug. The IEEE standard since 1985 has been to "round to nearest even" or "banker's rounding" which reduces bias across aggregate calculations.

We only just noticed this bug at my office. The following C++ code on x64/x86 exhibits the issue, as it is part of the crt, not the compiler:

#include

int main () {
char str[30];
sprintf(str, "%.0lf", 2.5);
std::cout << str;
}

The output should be "2" but is still giving "3". I think this update is part of 21H2 but don't quote me on it. I have yet to find the change log.

Steps to reproduce

#include

// Type your code here, or load an example.
int main () {
char str[30];
sprintf(str, "%.0lf", 2.5);
std::cout << str;
}

Expected behavior

Output: 2

Reproduction link

Not applicable

Screenshots

Not applicable

Operating System

Windows 10

Browser version

Firefox 99.01

@tjaurini tjaurini added the bug label Apr 26, 2022
@mattgodbolt
Copy link
Member

Hi! Can you please make a link so we can see what you're seeing? Thanks!

@OfekShilon
Copy link
Member

@mattgodbolt I'm able to reproduce: https://godbolt.org/z/h3Pbarre3

@pmor13
Copy link

pmor13 commented May 4, 2022

FYI: Fixed in 19.32.31302:

$ cat t67.cpp
#include <iostream>

int main () {
    char str[30];
    sprintf(str, "%.0lf", 2.5);
    std::cout << str;
}

$ cl t67.cpp /EHsc
Microsoft (R) C/C++ Optimizing Compiler Version 19.32.31302 for x64

$ ./t67.exe
2

Similar issue: https://stackoverflow.com/q/68851345/1778275.

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

No branches or pull requests

4 participants