[Bug c/28195] New: << (shift operator) does rotate operation

tetsuji dot rai at gmail dot com gcc-bugzilla@gcc.gnu.org
Wed Jun 28 17:57:00 GMT 2006


When shift count is the same as the length of a variable (eg, l << 32 where
long int l;), this doesn't return 0, instead it returns a rotated value.

Below is assumed to return 0, but actually returns 2468.

---t2.c---(test case)
#include <stdio.h>

long long ll;
long l;

int
main(){
  l = 1234;
  ll = l << 33;
  printf("%lld\n", ll);

  return 0;
}
--------------------


-- 
           Summary: << (shift operator) does rotate operation
           Product: gcc
           Version: 3.4.6
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: tetsuji dot rai at gmail dot com
 GCC build triplet: ia32 Gentoo Linux
  GCC host triplet: ia32 Gentoo Linux
GCC target triplet: ia32 Gentoo Linux


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28195



More information about the Gcc-bugs mailing list