(Cpp) fix inconsistent side-effect detection