Visual Studio 2010中的x64优化错误 [英] x64 optimization bug in Visual Studio 2010

查看:105
本文介绍了Visual Studio 2010中的x64优化错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


以下代码在Release x64配置中产生错误输出:

 #include<的iostream> 
#include< vector>

int wmain(int argc,wchar_t * argv [])
{
std :: vector< size_t> S; / * 1 * /

size_t volatile three = 3;
size_t volatile 4 = 4;

size_t a = 3;
size_t b = 4;

if(a!= b)
{
size_t n = std :: min(a,b); / * 2 * /
size_t x = std :: max(a,b);

std :: cout<< n<<的std :: ENDL;
std :: cout<< x<<的std :: ENDL;
}

返回0;
}

实际产量:4 4


预期产量: 3 4


如果我删除行/ * 1 * /或将/ * 2 * /更改为< b? a:b;它按预期工作。


释放Win32按预期工作。

调试x64按预期工作。

解决方案

确认。该错误发生在Visual Studio 2010中,但已在Visual Studio 2012 RC中得到修复。


显然,Microsoft必须注意这一点,但我建议无论如何都要向http:// connect提交报告。 microsoft.com。


Hi,

The following code produces incorrect output in Release x64 configuration:

#include <iostream>
#include <vector>

int wmain(int argc, wchar_t* argv[])
{
    std::vector<size_t> s;				/* 1 */

    size_t volatile three = 3;
    size_t volatile four = 4;

    size_t a = three;
    size_t b = four;

    if (a != b)
    {
        size_t n = std::min(a, b);		/* 2 */
        size_t x = std::max(a, b);

        std::cout << n << std::endl;
        std::cout << x << std::endl;
    }

    return 0;
}

Actual output: 4 4

Expected output: 3 4

If I remove line /* 1 */ or change /* 2 */ to a < b ? a : b; it works as expected.

Release Win32 works as expected.
Debug x64 works as expected.

解决方案

Confirmed. The bug is in Visual Studio 2010 but has been fixed in Visual Studio 2012 RC.

Obviously, Microsoft must be aware of this but I suggest submitting a report anyway to http://connect.microsoft.com.


这篇关于Visual Studio 2010中的x64优化错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆