明确初始化DWORD 1,但调试器显示出来似地范围的值 [英] Explicitly initialize DWORD to 1, but debugger shows wildly out of range value

查看:180
本文介绍了明确初始化DWORD 1,但调试器显示出来似地范围的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有点这个问题flabberghasted - 在调试模式这个问题上并没有拿出所有,但在发布模式下,感觉就像有几乎没有什么我可以做些什么来解决这个问题。

I'm a bit flabberghasted with this issue - in debug mode this issue doesn't come up at all, but in release mode it feels like there's almost nothing I can do to fix it.

下面是发生了什么事情里面VS2013的截图:

Here's a screenshot of what's going on inside VS2013:

我初始化 nResult 至1L,内部值显示为3422785012.在调试模式下,这个数值的确是1L。

I initialize nResult to 1L, and the internal value is shown as 3422785012. In Debug mode, this value is indeed 1L.

任何想法,为什么显示值甚至还没有接近我为 nResult 设定初始值?我试着编译器设置播放 - 在调试模式下此code运行正常。

Any ideas as to why the displayed value isn't even close to the initial value I set for nResult? I've tried playing with compiler settings - in Debug mode this code runs fine.

推荐答案

您code是更可能优化。这意味着,编译器和移动的方式,你的源$ C ​​$ C不匹配,编译器产生了淘汰code。

Your code is more than likely optimized. This means that the compiler has moved and eliminated code in a way that your source code does not match what the compiler has produced.

无论是调试未优化code或与完整的知识源可能不符合实际的指导调试优化code正在执行。

Either debug unoptimized code, or debug optimized code with the full knowledge that the source may not match the actual instructions being performed.

如果你想调试发布版本,但看到在调试器中正确的价值观,去在Visual Studio项目的属性,转到C / C ++部分,并禁用优化。重建。

If you want to debug a release build but see the correct values in the debugger, go to the Properties of your project in Visual Studio, go to the C/C++ section, and disable the optimizations. Rebuild.

这篇关于明确初始化DWORD 1,但调试器显示出来似地范围的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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