LWHists: Fix cppcheck warnings.
cppcheck warnings:
- assert with side effects.
- x!=x instead of isnan.
- calling virtual function from destructor.
- undefined/implmentation-defined bit shifting behavior.
- passing std::string::c_str() to a std::string argument.