Visual Studio C++ compiler empty functions
-
Does anyone know if the Visual Studio C++ compiler optimizes to eliminate calls to functions with empty definitions (nothing between the curly braces denoting the function's body)? I am particularly interested in the 2010 and 2012 versions of the Visual Studio compiler. Thank you.
-
Does anyone know if the Visual Studio C++ compiler optimizes to eliminate calls to functions with empty definitions (nothing between the curly braces denoting the function's body)? I am particularly interested in the 2010 and 2012 versions of the Visual Studio compiler. Thank you.
It would be easy enough for you to find this out for yourself. Create a small test program with such a function, and use Disassembly View to step through the code where the function is called. OTOH, these are the two optimizations that I do know about: 1. It combines functions that have identical definitions, and 2. It eliminates functions that are never called Both of these optimizations can be turned off in the Options dialog box.
The difficult we do right away... ...the impossible takes slightly longer.
-
Does anyone know if the Visual Studio C++ compiler optimizes to eliminate calls to functions with empty definitions (nothing between the curly braces denoting the function's body)? I am particularly interested in the 2010 and 2012 versions of the Visual Studio compiler. Thank you.
It depends on whether the method is virtual. It would theoretically be possible to eliminate all calls to empty non-virtual methods. A virtual method may be overridden by a derived class, so the compiler must perform the virtual call. (There may be some cases where the compiler can prove that the virtual call refers to the base class. In this case, the compiler could optimize the call away.) As Richard suggests, the best way to check this is to write a short test program.
If you have an important point to make, don't try to be subtle or clever. Use a pile driver. Hit the point once. Then come back and hit it again. Then hit it a third time - a tremendous whack. --Winston Churchill
-
Does anyone know if the Visual Studio C++ compiler optimizes to eliminate calls to functions with empty definitions (nothing between the curly braces denoting the function's body)? I am particularly interested in the 2010 and 2012 versions of the Visual Studio compiler. Thank you.
Yes, the compiler will eliminate useless calls (maybe not in DEBUG mode, but surely in RELEASE mode). today's compiler are a lot more smarter than you can imagine. Is there a particular reason for this question?
I'd rather be phishing!