In Visual Studio 2017, I have create a .natvis debugger visualization rule which calls a C++ function.
In the debugger it shows:
This expression has side effects and will not be evaluated.
Beside this, it shows a little blue arrow that can be clicked on to force it to evaluate, and then it actually does call the function. (I think this might be a recent feature, because I seem to remember trying this in VS2013 and don't remember it having a bypass)
My question is: Is there some way I can permanently bypass this safety check, so that it always evaluates my function immediately and doesn't require me to click on the arrow?
I have looked at a very similar question: "This expression causes side effects and will not be evaluated". How to suppress? where the accepted answer is only valid for C# (adding ,ac on the end of a C# expression forces the debugger to automatically re-evaluate it)
I imagine if such a thing existed it would be one of the following mechanisms:
- A registry setting or other global setting that disables the safety check all the time.
- A way of annotating the code or the .natvis rule so that the compiler knows somehow that it's a safe and pure side-effect-free function
To give a bit more detail about the application: We use uint32's all over the place in our code which are hashed from strings, and we have a database of the strings loaded only in development builds. The decoding function looks up the u32 ID in a binary search tree, returning the string found in the stored node. So I know that it's entirely side-effect-free and sufficiently fast that it not impair the debugging experience to just call the function each time the .natvis rule says so.