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

<iostream>: Writing NaN to the output stream with a set locale results in a weird output #3867

Closed
fsb4000 opened this issue Jul 12, 2023 · 0 comments · Fixed by #3868
Closed
Labels
bug Something isn't working fixed Something works now, yay!

Comments

@fsb4000
Copy link
Contributor

fsb4000 commented Jul 12, 2023

Command-line test case

C:\Temp>type main.cpp
#include <iostream>
#include <locale>
#include <cmath>

int main()
{
    std::cout << (long double)std::sqrt(-1) << std::endl;
    std::cout << (double)std::sqrt(-1) << std::endl;
    std::cout << (float)std::sqrt(-1) << std::endl;

    std::cout.imbue(std::locale("en_us"));
    std::cout << (long double)std::sqrt(-1) << std::endl;
    std::cout << (double)std::sqrt(-1) << std::endl;
    std::cout << (float)std::sqrt(-1) << std::endl;

    return 0;
}

C:\Temp>cl /EHsc /W4 /WX /std:c++latest .\main.cpp
Microsoft (R) C/C++ Optimizing Compiler Version 19.37.32820 for x64
Copyright (C) Microsoft Corporation.  All rights reserved.

/std:c++latest is provided as a preview of language features from the latest C++
working draft, and we're eager to hear about bugs and suggestions for improvements.
However, note that these features are provided as-is without support, and subject
to changes or removal as the working draft evolves. See
https://go.microsoft.com/fwlink/?linkid=2045807 for details.

main.cpp
Microsoft (R) Incremental Linker Version 14.37.32820.0
Copyright (C) Microsoft Corporation.  All rights reserved.

/out:main.exe
main.obj

C:\Temp>.\main.exe
-nan(ind)
-nan(ind)
-nan(ind)
-na,n(i,nd)
-na,n(i,nd)
-na,n(i,nd)

Expected behavior

Should be -nan(ind) for every output

STL version

Microsoft Visual Studio Community 2022
Version 17.7.0 Preview 3.0

Additional context

Devcom-10410933 / VSO-1848294 / AB#1848294

@fsb4000 fsb4000 changed the title <iostream>: Wrong output for NaN <iostream>: Writing NaN to the output stream with a set locale results in a weird output Jul 12, 2023
@StephanTLavavej StephanTLavavej added the bug Something isn't working label Jul 12, 2023
@StephanTLavavej StephanTLavavej added the fixed Something works now, yay! label Jul 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working fixed Something works now, yay!
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants