[Bug c/38341] New: Wrong warning comparison of promoted ~unsigned with unsigned

fredrik dot hederstierna at securitas-direct dot com gcc-bugzilla@gcc.gnu.org
Mon Dec 1 08:36:00 GMT 2008


Compiler gives wrong warning for "comparison of promoted ~unsigned with
unsigned" when compiling with ARM-ELF.

Submit script for building arm-elf toolchain and testcode.

Compilation using;

arm-elf-gcc -c cast.c -W
cast.c: In function 'test_cast':
cast.c:13: warning: comparison of promoted ~unsigned with unsigned

Best Regards
Fredrik Hederstierna

============
FILE: cast.c
============

typedef unsigned char u8_t;
void test_cast(void) {
  unsigned char c1 = 0;
  unsigned char c2 = 0;  
  u8_t u1 = 0;
  u8_t u2 = 0;  
  if (c1 == (unsigned char)(~c2)) {
  }
  if (u1 == (u8_t)(~u2)) {  // THIS WILL GIVE WARNING
  }
}



========================
FILE: build_toolchain.sh
========================

set -e -x 

TARGET=arm-elf 

BINUTILS_VERSION=2.19
GCC_VERSION=4.3.2
NEWLIB_VERSION=1.16.0
GDB_VERSION=6.8
INSIGHT_VERSION=6.8

DEST="/usr/local/gcc/arm-elf-tools-$GCC_VERSION"

BINUTILS_DIR="binutils-$BINUTILS_VERSION" 
GCC_DIR="gcc-$GCC_VERSION" 
NEWLIB_DIR="newlib-$NEWLIB_VERSION" 
GDB_DIR="gdb-$GDB_VERSION"
INSIGHT_DIR="insight-$INSIGHT_VERSION"

# set rwx access

umask 022 

# unpack tar-balls

rm -fr "$BINUTILS_DIR" "$GCC_DIR" "$NEWLIB_DIR" "$GDB_DIR" "$INSIGHT_DIR"
tar xvjf "binutils-$BINUTILS_VERSION.tar.bz2" 
tar xvjf "gcc-$GCC_VERSION.tar.bz2" 
tar xvzf "newlib-$NEWLIB_VERSION.tar.gz" 
tar xvjf "gdb-$GDB_VERSION.tar.bz2" 
tar xvjf "insight-$INSIGHT_VERSION.tar.bz2" 

cd "$GCC_DIR"
ln -s "../$NEWLIB_DIR/newlib" newlib 
ln -s "../$NEWLIB_DIR/libgloss" libgloss 
cd ..

rm -fr build 
mkdir -p build/binutils build/gcc build/gdb build/insight build/newlib

# Build binutils

cd build/binutils 
"../../$BINUTILS_DIR/configure" --target="$TARGET" --prefix="$DEST"
--disable-nls
make LDFLAGS=-s all install 

# Build GCC

cd ../gcc 
PATH="$DEST/bin:$PATH" 
"../../$GCC_DIR/configure" --enable-languages=c,c++ --target="$TARGET"
--prefix="$DEST" --with-gnu-as --with-gnu-ld --disable-nls --with-newlib
--disable-__cxa_atexit --with-ecos
make LDFLAGS=-s all all-gcc all-target-libstdc++-v3 install install-gcc
install-target-libstdc++-v3

# Build GDB and Insight

cd ../gdb
# Without insight
"../../$GDB_DIR/configure" --target="$TARGET" --prefix="$DEST"
make -w all install

cd ../insight
# With insight
"../../$INSIGHT_DIR/configure" --target="$TARGET" --prefix="$DEST"
make -w all install

# Remove uncompressed sources

cd ../.. 
rm -fr "$BINUTILS_DIR" "$GCC_DIR" "$NEWLIB_DIR" "$GDB_DIR" "$INSIGHT_DIR" build


-- 
           Summary: Wrong warning comparison of promoted ~unsigned with
                    unsigned
           Product: gcc
           Version: 4.3.2
            Status: UNCONFIRMED
          Severity: minor
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: fredrik dot hederstierna at securitas-direct dot com
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: arm-elf-gcc


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



More information about the Gcc-bugs mailing list