http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38470
David Stone <DeusExSophismata at gmail dot com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |DeusExSophismata at gmail | |dot com --- Comment #10 from David Stone <DeusExSophismata at gmail dot com> 2012-03-24 06:52:04 UTC --- Simple self-contained test case: unsigned f (int x) { return (x >= 0) ? x : -x; } int main () { return 0; } It seems like we could at least add a simple improvement that just checks for simple comparisons to 0. That probably catches most code (I often do one set of calculations for non-negative values, and another set for negative values) and avoids a lot of problems of trying to track complex calculations for the signedness of the result. I wouldn't be perfect, but it would be better than it currently is. Being able to detect cases like this is also an optimization opportunity, because division with positive integers is simpler than division with negative integers, for example. We could reuse code that detects that optimization opportunity for this warning.