Hello! This might not apply to g++ 4.1.2, which is what you use, but I don't have this version right here to test it. It works fine for gentoo's g++ 4.1.1 and produces no warnings: template <int a> int shift (int b) { if (a > 0) { unsigned ua = a; return b >> ua; } else { unsigned ua = -a; return b << ua; } } template int shift<1>(int); template int shift<-1>(int); However, you will have to turn on optimization in order to get the same efficient code than with your version (x86 here). (I do get a warning for converting -1 to unsigned on g++ 3.4.6) jlh