https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63420
Bug ID: 63420 Summary: GCC 4.8.2: Bitshift second operand range not as per manual. Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: aainscow at uk dot ibm.com Created attachment 33625 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=33625&action=edit Demo code Most likely this is simply a problem with the GCC manual. The GCC documentation states (30th Sept 2014): -- You use the left-shift operator << to shift its first operand's bits to the left. The second operand denotes the number of bit places to shift. Bits shifted off the left side of the value are discarded; new bits added on the right side will all be 0. ... For both << and >>, if the second operand is greater than the bit-width of the first operand, or the second operand is negative, the behavior is undefined. -- NOTE: "greater than" not "greater than or equal to". The following code should therefore not be undefined and return 0. int main() { int a = sizeof(int)*8; return ((int)1) << a; } However: aainscow@morwenna:~/cake$ gcc bitshift_bug.c aainscow@morwenna:~/cake$ ./a.out ; echo $? 1 Most likely this is a problem with documentation.