From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 31148 invoked by alias); 27 Nov 2007 12:08:27 -0000 Received: (qmail 31027 invoked by uid 48); 27 Nov 2007 12:08:13 -0000 Date: Tue, 27 Nov 2007 12:08:00 -0000 Message-ID: <20071127120813.31026.qmail@sourceware.org> X-Bugzilla-Reason: CC References: Subject: [Bug c/34235] short variable cast to unsigned int fails to right shift as unsigned In-Reply-To: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "fgccbz1 at greynode dot net" Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2007-11/txt/msg02601.txt.bz2 ------- Comment #2 from fgccbz1 at greynode dot net 2007-11-27 12:08 ------- Sorry - it looks like compiling as c++ is required. I thought I'd eliminated that issue in my original analysis, but evidently I was wrong. I see the weird behavior just when compiling with g++ cast.c -o cast but not with gcc cast.c -o cast (I'll attach my exact cast.c) I see the issue using the redhat-built compilers on my Fedora 7 machine: $ g++ -v Using built-in specs. Target: x86_64-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-languages=c,c++,objc,obj-c++,java,fortran,ada --enable-java-awt=gtk --disable-dssi --enable-plugin --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-1.5.0.0/jre --enable-libgcj-multifile --enable-java-maintainer-mode --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --with-cpu=generic --host=x86_64-redhat-linux Thread model: posix gcc version 4.1.2 20070925 (Red Hat 4.1.2-27) also with my own build of gcc from a controlled environment, using straight gnu source, with binutils-2.16.1: $ gcc -v Using built-in specs. Target: x86_64-unknown-linux-gnu Configured with: /localdisk/dev_tools_build/dev_tools/source/gcc-4.1.2/configure --prefix=/usr/dev_tools/170681 --libdir=/usr/dev_tools/170681/lib64 --enable-languages=c,c++ --with-gnu-as --with-as=/usr/dev_tools/170681/bin/as --with-gnu-ld --with-ld=/usr/dev_tools/170681/bin/ld Thread model: posix gcc version 4.1.2 As a side note I'll mention I also saw the problem using an old version of gcc-2.95.3 I had lying around, but I don't know the provenance of that compiler. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34235