Silence GCC -Wcast-qual warning

Use C++ casts instead of C-style casts in order to silence warning about casting away qualifiers.

warning: cast from type 'volatile bool*' to type 'bool*' casts away qualifiers [-Wcast-qual]