双重到`unsigned long long`导致内存(堆栈?)损坏

时间:2012-12-05 13:47:15

标签: c++ casting visual-studio-2012 unsigned-long-long-int

以下代码有什么问题(崩溃):

#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

它适用于x64以及我们将unsigned long long更改为long long甚至unsigned long

此代码段崩溃。在其他情况下,功能参数的地址会发生变化。

我怀疑它与_stol2有关,将double转换为unsigned long long

1 个答案:

答案 0 :(得分:1)

Submitted to Microsoft作为错误(已接受)