Sign in to follow this  
nuclear123

MSVC++ 2010 optimization option?

Recommended Posts

nuclear123    119
does anyone know of a way to allow full optimizations of code compiled on MVC++ 2010 except for the elimination of code that performs nothing relevant. For example


[code]int main()
{
int var;

var++;

return 0;
}[/code]


[code]
_main PROC ; COMDAT

; 3 : int var;
; 4 :
; 5 : var++;
; 6 : return 0;

xor eax, eax

; 7 : }

ret 0
_main ENDP[/code]

since var++ doesnt get stored in a variable it's operation is omitted when the binary is compiled from MSVC++. What exact option can i change in order to prevent this while leaving other optimizations on!?

Share this post


Link to post
Share on other sites
kdmiller3    178
If you're trying to create a location where you can place a debugger breakpoint, you can insert a nop instruction via inline assembly (__asm nop) or a compiler intrinsic (__nop()). I haven't tried the compiler intrinsic but the optimizer definitely won't try to remove inline assembly.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this