Fix GCC 8 cast warnings