https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66622
Mikhail Maltsev <miyuki at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |diagnostic CC| |miyuki at gcc dot gnu.org Severity|normal |enhancement --- Comment #1 from Mikhail Maltsev <miyuki at gcc dot gnu.org> --- That is possible to implement, but not easy. The compiler transforms code in such a way that lots of information is lost and it's hard to tell which code was written by user, and which was generated by the compiler. Very few warnings are actually emitted at the stage when data flow (use-def chains and value ranges) is known (for example -Wmaybe-uninitialized, but it has rather frequent false positives: https://gcc.gnu.org/bugzilla/buglist.cgi?quicksearch=Wmaybe-uninitialized). In your case the program will look like this at very early stage: unsigned foo(int i) { unsigned result; if (i < 0) goto bb1; else goto bb2; bb1: result = 0; return result; bb2: result = (unsigned)i; return result; } Later it will be impossible to say, whether the conversion was introduced explicitly by user, or by the compiler. Clang also gives false positive. EDG does not warn for such conversions (even unconditional).