I have a program which runs fine in debug build , but when I run the same with release build my program crashes at below lines
char* iter=ptr; //ptr is already initialized
char* iter = (char*) ALIGN (iter); // crashes here
I have a preprocessor definition like below for ALIGN
Type-casting of pointers to long.
#define SIZE 8L
#define ALIGN(ptr) \
(((__int64)ptr & (~(SIZE - 1L))) + SIZE) \
: (__int64)ptr)
It only gives problem when I run this program in Visual Studio 2012 in windows 8 but works fine with Visual studio 2012 in windows 7 . I dont know what flags(may be optimization flags) we have to set or unset for my program to work in release mode.
Please suggest me a solution
What you're doing is, basically
char* iter = iter;
If the variable iter
is declared as a local variable, its contents will be indeterminate, and using that value will lead to undefined behavior. That includes using that value to initialize itself.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.