http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60619
Bug ID: 60619 Summary: new -solve-sign-conflicts at -Wsign-compare cases (easy work) Product: gcc Version: 4.8.2 Status: UNCONFIRMED Severity: enhancement Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: aleks at physik dot tu-berlin.de GCC detects sign problems (-Wconversion -Wsign-compare -Wsign-conversion). int i; unsigned u; if (u == i) // warning sign .. my gcc feature suggestion: new -solve-sign-conflicts ==> some problems could be solved by gcc alone (if switch). I could provide compare functions, that are used by gcc in case of above warning and the new switch. // e.g. 3 compare functions, handle signs inline int cmp_su32_equal(int s, uint32 u) { /* == */ const int o = s | (int) u; if (s != (int) u) return 0; if (o < 0) return 0; // (s<0) || (u>INT_MAX) return 1; } inline int cmp_su32_lt(int s, uint32 u) { /* < */ const int o = s | (int) u; if (o < 0) return 1; // (s<0) || (u>INT_MAX) if (s < (int) u) return 1; return 0; // return (s < (int) u); } inline int cmp_su32_gt(int s, uint32 u) { /* > */ const int o = s | (int) u; if (o < 0) return 0; // (s<0) || (u>INT_MAX) if (s > (int) u) return 1; return 0; // return (s > (int) u); }