Code is not compiling for memset

Hi,
I have a very big c file.
In that one function calls a memset ( in my previous post I have post about memset)
it set a array whose size is 1006.

but it fills the array with space for 997.
memset(arr,' ',997); // why 997 and not 1006 that I do not know

then it calls memcpy(arr,source,200); // copies 200 character from source.

This is working fine as per purpose. This is compiled and build in 2005 visual studio.

Now it is being compiled with 2008 visual studio.

Still it is working fine in debug mode .

-------- The problem comes in release mode-----------

When i build it with release mode it is skiping the line memset(arr,' ',997);
( i tried to put break point in release mode but it is not allowing to put break point there)
pressing F10 it skips the line.

------- Now the intresting thing-------------------
I cut that line and paste below the line memcpy(arr,source,200) and tried to initialize it like
memset(arr+200,' ',997-200);
It worked perfectly.

Please help me out in fixing this behaviour is happening in visual studio 2008.
Any idea why it is not executing the memset line in release mode. While it is executing it in debug mode.
In that one function calls a memset ( in my previous post I have post about memset)


What other post? According to your post count you've only posted on this forum once.

Give us a link.

Anyway weird behavior like this could be a sign of heap corruption. But it's hard to say without seeing the code.
closed account (1yR4jE8b)
Your release mode settings may have certain optimizations enabled, as soon as you enable optimizations then the assembly changes so adding breakpoints is impossible. The compiler is probably optimizing the memset away for some reason (hence why you can't put a breakpoint).

Try turning off compiler optimazations, unfortunately I don't use Visual Studio so I have no idea how to do that for you.
Topic archived. No new replies allowed.