std::locale(const char*) freezes … sometimes. Visual Studio bug?


  • Consider the following code:

        #include <sstream>
        #include <iostream>

        int main()
            std::stringstream ss;

            //auto loc = std::locale("de-DE");  // A
            auto loc = std::locale("");         // B

            ss << ((double)1.01);

            std::cout << "standard formatting:  " << (double)1.01 << std::endl;
            std::cout << "localized formatting: " << ss.str() << std::endl;

    Now, this works as expected or it freezes in line B. When using line A it is the same but I think that changing from A to B or vice versa leads to a higher chance that it works. It even happened that it worked one time and starting it again it freezes in line A or B respectively.

    It is important that all this happens only when I start debugging from within VS 2015. When I execute this program from console it never freezes (release or debug doesn't matter).

    So is this a Visual Studio bug?

    Edit: Adding more context:

    • I'm running VS 2015 Enterprise, Update 1.
    • The code above resides in a console project (Configuration Type: Application (.exe), compiled with /SUBSYSTEM:CONSOLE). Although, again, this is only reproducible starting debugging from within Visual Studio, for example by pressing F5 while Debug build configuration is active.
    • The freeze happens even when starting VS in safe mode.

    • Edited by THuMorgen Tuesday, February 23, 2016 12:28 PM context added
    Friday, February 19, 2016 8:59 AM

All replies

  • Hi THuMorgen,

    Do you mean this problem just occurs in other project type? Does it works fine in Console project?

    I create a Universal app and copy you code into a button click event. When I start debugging my Universal app, no matter I use line A nor line B, both of them works fine in my side. I'm using Visual Studio Enterprise 2015 Update 1. Please check whether you have install the Update 1.

    Then please run your Visual Studio as administrator to make sure it has enough permission doing all operations.

    Please also try run your Visual Studio in safe mode with "Deven.exe /SafeMode" command to prevents all third-party VSPackages from loading when Visual Studio starts, thus ensuring stable execution. Please make sure you have closed all third part software when running Visual Studio, such as antivirus.

    In addition, please check the ActiveLog.xml under the path of %AppData%\Microsoft\VisualStudio\14.0. This file will log all operations when you operate Visual Studio.

    Best Regards,

    Monday, February 22, 2016 4:52 AM
  • Hello Weiwei,

    thank you for your suggestions. I answered some of your questions and suggestions in my original post.

    I will not deactivate my the antivirus software of my company. If VS cannot cope with Norton I consider it a bug in VS.

    Finally I checked the ActivityLog.xml. But all entries are from 2015, so I didn't find related information there.

    • Edited by THuMorgen Tuesday, February 23, 2016 12:47 PM
    Tuesday, February 23, 2016 12:46 PM
  • Hi THuMorgen,

    I also tested your code in Console application and it works fine in my side. So I don't think it is caused by your code.

    Please use  to gather the VS and .Net Frameowrk installation logs. After using it, you will find from %temp% folder. Please upload the file to Onedrive and share the link here.

    Best Regards,

    Wednesday, February 24, 2016 1:45 AM