C++ fix: omit if-then-else variable assignment when the type is void