This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c/34235] short variable cast to unsigned int fails to right shift as unsigned



------- 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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]