UPDATE: This question was the subject of my blog on Monday November 29th 2010.
Thanks for the great question!
You get rid of the warning by first thinking about the warning and deciding if the compiler is right to bring the problem to your attention in the first place! Are you in fact going to get incorrect results from the bitwise or should the conversion from a signed type to a larger unsigned type sign-extend the integer?
If the answer is yes then your solution is wrong. Don't eliminate the warning by tricking the compiler into still doing the wrong thing without giving you the warning. Eliminate the warning by doing the right thing: don't use a conversion that sign-extends the integer.
If the answer is no, and you want the sign extension then your solution or Hans Passant's solution is correct. However, I would put a comment to that effect in the code, because as it stands, it is hard to see that the sign extension is desirable.