This is a follow-up to http://gcc.gnu.org/ml/gcc-help/2010-06/msg00005.html :
Consider the following case: uint32_t foo, bar; ... foo = bar << 20; Of course, this operation can overflow and warning about this probably does not make sense as the programmer should be aware of this case. However, a warning in the following case could be appropriate IMO: uint32_t bar; uint64_t foo; ... foo = bar << 20; The intension is to catch the overflow case, therefore the assignment to a 64-bit variable. The intended code would be uint32_t bar; uint64_t foo; ... foo = (uint64_t)bar << 20; I think it would be a big help if gcc could warn in the 2nd case. -- Summary: [feature request] Warn for certain integer overflows Product: gcc Version: 4.6.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: middle-end AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: fm3 at os dot inf dot tu-dresden dot de http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44420