Skip to content

Visual Studio 2022 std::system_category returns "unknown error" if system locale is not en-US #3254

@cppdev123

Description

@cppdev123

I download visual studio 2022 17.4.1 and was surprised to see that "unknown error" is returned from std::error_code using std::system_categoey() as the error category while it was reporting the correct error message before.
After searching on the internet, I found someone complaining about the same issue here : "unknown error" from std::error_code on Windows
The solution was to set the system locale to en-US from "administrative language settings".

I tested it on two windows installations:
Windows 11 with locale set to "en-GB" and worked well when changed to "en-US"
Windows 10 with locale set to "ar-EG" and worked well when changed to "en-US"

I have also visual studio 2019 installed and the binary produced by it works as expected without needing to change the system locale

The issue seems to have appeared in __std_system_error_allocate_message in syserror_import_lib.cpp after this commit <system_error>: explicitly pass the system locale ID for system_categ…

To mention also: both windows installs have "English (United States)" as the "Windows display language" but had system locale different from "en-US"

EDIT: I set both display language and system locale to "ar-EG" but still "unknown error" is returned. Only when system locale is set to en-US the correct message is returned disregarding the display language

Also tracked by internal VSO-1735227 / AB#1735227 .

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingfixedSomething works now, yay!

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions