C++ Question logging a variable changes the result... impossible to understand

I get your point, but I do initialize variables on declaration anyway, unless not doing it provides some benefit, as in my first example.

So for me it's initialize on declaration always, unless... :)
 
My guess for the original question would be that without the logging statement, vel is getting optimized out by the compiler.

How are you actually returning the value from this calculation? This also seems to be a case of not actually posting enough code for other people to figure out what's going on :)
 
Back
Top