https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70389
Bug ID: 70389 Summary: uint_16t left shift with -Wconversion produces incorrect warning Product: gcc Version: 4.8.2 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: bobgmeyers at muchomail dot com Target Milestone: --- This code: int main(void){ uint16_t x; x=5; do{ x<<=1U; x++; }while(1); } The code obviously outputs nothing, but this is just an example of this bug which happens in every case as described below. with -Wconversion it produces: warning: conversion to ‘uint16_t’ from ‘int’ may alter its value [-Wconversion] x<<=1U; How on earth could x<<1U end up being an int? x isn't signed and 1U isn't signed (and according to the spec, the type of 1U is not relevant to the type of x<<1U). I tried uint32_t and the error went away, so it looks like a problem with uint16_t. Right shift is also OK. Might relate to: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59840 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=34389