I personally would never dare to write any code that could result in an expression like: 1 << -1
Unfortunately I found some code that uses it. Eventually I learned that the following code behaves differently on i386 and ppc64: #include <stdio.h> int main(int argc, char *argv[]) { int shifter = 0; unsigned int target = 0; target |= (1 << (shifter -1)); printf("%x\n", target); } On i386, it prints 80000000. On ppc64, it prints 0. Should gcc be changed to be consistent across platforms? It might help those that platforms that are being used less frequently. -- Summary: 1 << -1 inconsistent across platforms Product: gcc Version: 4.1.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: kengert at redhat dot com GCC build triplet: ppc64-yellowdog-linux GCC host triplet: ppc64-yellowdog-linux GCC target triplet: ppc64-yellowdog-linux http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35213