Visual Studio 2012发行版中的问题

Gee*_*dow 0 c++ windows-8 visual-studio-2012

我有一个在调试版本中运行良好的程序,但是当我在发布版本中运行时,我的程序在下面的行中崩溃了

char* iter=ptr; //ptr is already initialized

char* iter = (char*) ALIGN (iter); // crashes here
Run Code Online (Sandbox Code Playgroud)

对于ALIGN,我有一个类似下面的预处理器定义

指向long的指针的类型转换.

#define SIZE       8L
#define ALIGN(ptr)  \
    (((__int64)ptr & (~(SIZE - 1L))) + SIZE) \

       : (__int64)ptr)
Run Code Online (Sandbox Code Playgroud)

它只在我在Windows 8中的Visual Studio 2012中运行此程序时出现问题,但在Windows 7中与Visual Studio 2012一起正常工作.我不知道我们必须设置或取消设置哪些标志(可能是优化标志)以使我的程序在发布模式下工作.
请建议我一个解决方案

Som*_*ude 5

你在做什么,基本上

char* iter = iter;
Run Code Online (Sandbox Code Playgroud)

如果变量iter声明为局部变量,则其内容将是不确定的,并且使用该值将导致未定义的行为.这包括使用该值来初始化自己.