------- Comment #20 from pcarlini at suse dot de 2006-01-25 12:20 ------- (In reply to comment #19) > Just a small update. On one of our projects we have now thousands of warnings > on the test "x < 0" for the function below, when Type is instantiated to an > unsigned integral type: > > template <typename Type> > inline Result > sgn_generic(const Type& x) { > if (x < 0) > return V_LT; > if (x > 0) > return V_GT; > return V_EQ; > }
A side remark, about a weird workaround I had to use in the past in the library (yes the problem is real, I agree, not sure about the best solution, however). Would boil down to something like (mosulo stupid typos ;) if (x > 0) return V_GT; else if (x) return V_LT; return V_EQ; Seems correct to me and doesn't incur in any warning. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12963