yep, you're right. I've updated the patch.

(I'm now obliged to think that GCC also had some problems here, but they were papered over because GCC seems to evaluate the static_cast later than clang...)