Question

What is wrong with the following code (crashes):

#include <string>
#include <iostream>

void foo(std::string str, unsigned long long val)
{
    std::cout<< str<< " "<< val<< std::endl; // Crashes if commented as well
}

int main()
{
    double d = 30.0;
    foo("abc", d);
}

Visual Studio 2012/ Debug/ Win32

It works in x64 as well as if we change the unsigned long long to long long or even unsigned long

This code snippet crashes. In other scenarios the addresses of the function parameters are changed.

I suspect it has something to do with _stol2 that converts the double to unsigned long long

Était-ce utile?

La solution

Submitted to Microsoft as a bug (Accepted)

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top