I'm trying to find out how exactly my compiler optimizes certain code.
The issue is that in any test program I have written MSVC will completely optimize out all the code knowing that it has no visible result!
For example, in an attempt to see how much the compiler can optimize this code:
(This is just a bad example)
Vector3D TestFn( float x, float y, float z )
return Vector3D( 1, 2, 3 ) * Vector3D( x, y, z );
Calling the function and saving the result will all simply be compiled out because it knows that I don't use the result.
How can I trick MSVC into thinking that the return value is used so it will not compile it completely out? Or something similar.
Vector a = TestFn( 4, 5, 6 );
EDIT: I'm looking at the assembly by the way, I want it to generate assembly as if I used the return value instead of generating nothing.