Tried a simple program that left shifts the long long  33 times, the result
displayed is wrong and not what is expected of shifting 1 <<33 


Sample code follows,


int main()
{
 unsigned long long var=1;
 long long m =1;

 printf(" %lu ", (var <<33));
 printf("\n %lu ", (m <<33));
 return 0;
}


Using built-in specs.
Target: i386-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man
--infodir=/usr/share/info --enable-shared --enable-threads=posix
--enable-checking=release --with-system-zlib --enable-__cxa_atexit
--disable-libunwind-exceptions --enable-libgcj-multifile
--enable-languages=c,c++,objc,java,f95,ada --enable-java-awt=gtk
--with-java-home=/usr/lib/jvm/java-1.4.2-gcj-1.4.2.0/jre
--host=i386-redhat-linux
Thread model: posix
gcc version 4.0.2 20051125 (Red Hat 4.0.2-8)
 /usr/libexec/gcc/i386-redhat-linux/4.0.2/cc1 -E -quiet -v macro.c -Wall
-fpch-preprocess -o macro.i
ignoring nonexistent directory
"/usr/lib/gcc/i386-redhat-linux/4.0.2/../../../../i386-redhat-linux/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/include
 /usr/lib/gcc/i386-redhat-linux/4.0.2/include
 /usr/include
End of search list.
 /usr/libexec/gcc/i386-redhat-linux/4.0.2/cc1 -fpreprocessed macro.i -quiet
-dumpbase macro.c -auxbase macro -Wall -version -o macro.s
GNU C version 4.0.2 20051125 (Red Hat 4.0.2-8) (i386-redhat-linux)
        compiled by GNU C version 4.0.2 20051125 (Red Hat 4.0.2-8).
GGC heuristics: --param ggc-min-expand=63 --param ggc-min-heapsize=63433
macro.c: In function ‘main’:
macro.c:18: warning: format ‘%lu’ expects type ‘long unsigned int’, but
argument 2 has type ‘long long unsigned int’
macro.c:19: warning: format ‘%lu’ expects type ‘long unsigned int’, but
argument 2 has type ‘long long int’
 as -V -Qy -o macro.o macro.s
GNU assembler version 2.15.94.0.2.2 (i386-redhat-linux) using BFD version
2.15.94.0.2.2 20041220
 /usr/libexec/gcc/i386-redhat-linux/4.0.2/collect2 --eh-frame-hdr -m elf_i386
-dynamic-linker /lib/ld-linux.so.2
/usr/lib/gcc/i386-redhat-linux/4.0.2/../../../crt1.o
/usr/lib/gcc/i386-redhat-linux/4.0.2/../../../crti.o
/usr/lib/gcc/i386-redhat-linux/4.0.2/crtbegin.o
-L/usr/lib/gcc/i386-redhat-linux/4.0.2 -L/usr/lib/gcc/i386-redhat-linux/4.0.2
-L/usr/lib/gcc/i386-redhat-linux/4.0.2/../../.. macro.o -lgcc --as-needed
-lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed
/usr/lib/gcc/i386-redhat-linux/4.0.2/crtend.o
/usr/lib/gcc/i386-redhat-linux/4.0.2/../../../crtn.o


-- 
           Summary: Shift more than 32 bits dosent work on a long long int
           Product: gcc
           Version: 4.0.2
            Status: UNCONFIRMED
          Severity: major
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: saurabh dot dobhal at gmail dot com


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

Reply via email to