I am updating from Visual Studio 2013 to Visual Studio 2015 and noticed this difference in behaviour.
#include <stdexcept>
#include <WinSock2.h>
#include <ws2tcpip.h>
int main()
{
WORD version = MAKEWORD(2, 2);
WSADATA wsaData;
if (WSAStartup(version, &wsaData) != 0)
{
throw std::runtime_error("This one is not thrown");
}
WSASetLastError(1);
if (WSAGetLastError() != 1)
{
throw std::runtime_error("This one neither");
}
#if 1
std::runtime_error test("an error");
#endif
if (WSAGetLastError() != 1)
{
throw std::runtime_error("This is thrown when the above code path is enabled");
}
return 0;
}
When I enable the std::runtime_error code path the WSAGetLastError flags is reset. Disable it and the program returns 0 without any problems.