You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
if _HAS_EXCEPTIONS is defined to 1 it seems exception class does copy the string
__std_exception_copy(&_InitData, &_Data);
but if _HAS_EXCEPTIONS = 0 the exception class only stores a pointer
constchar* _Ptr; // the message pointer
Command-line test case
C:\Temp>type repro.cpp
#include <iostream>
int main() {
std::string error_what("test system_error");
std::error_code error_code(0, std::system_category());
auto se = std::system_error(error_code, error_what);
std::puts(se.what());
}
C:\Test>cl /W4 /WX /D "_HAS_EXCEPTIONS=0" /MDd .\test.cpp
Microsoft (R) C/C++ Optimizing Compiler Version 19.34.31935 for x64
Copyright (C) Microsoft Corporation. All rights reserved.
test.cpp
Microsoft (R) Incremental Linker Version 14.34.31935.0
Copyright (C) Microsoft Corporation. All rights reserved.
/out:test.exe
test.obj
C:\Test>test.exe
¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦
Expected behavior
For the a proper message to be printed instead of garbage
C:\Test>cl /EHsc /W4 /WX /MDd .\test.cpp
Microsoft (R) C/C++ Optimizing Compiler Version 19.34.31935 for x64
Copyright (C) Microsoft Corporation. All rights reserved.
test.cpp
Microsoft (R) Incremental Linker Version 14.34.31935.0
Copyright (C) Microsoft Corporation. All rights reserved.
/out:test.exe
test.obj
C:\Test>test.exe
test system_error: La operaci¾n se complet¾ correctamente.
STL version Microsoft Visual Studio Community 2022 (64-bit) - Current Version 17.4.2 Additional context
At this point it's hard for me to assume that I found a legit bug and nobody is using _HAS_EXCEPTIONS=0
but all my c++ experts are in vacation already :) 🤷♂️
The text was updated successfully, but these errors were encountered:
system_error class gives runtime error a temporary std string
https://github.com/microsoft/STL/blob/main/stl/inc/system_error#L477
and runtime_error seems to pass a temporary string to exception
if _HAS_EXCEPTIONS is defined to 1 it seems exception class does copy the string
__std_exception_copy(&_InitData, &_Data);
but if _HAS_EXCEPTIONS = 0 the exception class only stores a pointer
Command-line test case
Expected behavior
For the a proper message to be printed instead of garbage
STL version
Microsoft Visual Studio Community 2022 (64-bit) - Current Version 17.4.2
Additional context
At this point it's hard for me to assume that I found a legit bug and nobody is using _HAS_EXCEPTIONS=0
but all my c++ experts are in vacation already :) 🤷♂️
The text was updated successfully, but these errors were encountered: