typesafe: fix warnings with gcc's -Wcast-qual