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

           Summary: unsigned int possible treated as signed in a
                    union/struct
           Product: gcc
           Version: 4.5.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassig...@gcc.gnu.org
        ReportedBy: tinokra...@web.de


Created attachment 22618
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=22618
a module

When compiling the attached file the compiler does not warn, but the assambler
gives the following error:
C:\DOKUME~1\tkr\LOKALE~1\Temp\ccqr1SmQ.s: Assembler messages:
C:\DOKUME~1\tkr\LOKALE~1\Temp\ccqr1SmQ.s:522: Error: immediate value out of
range -- `movt r3,-32768'
The line "dwCalcVal.u_16_values.u_16_value_1=0x8000u;" causes the error.
It looks to me like a singned-unsigned fault and in fact it is so. reducing the
constant to a value 0x0000 till 0x7FFF will compile without error.
The problem appears also only when:
- the value is at the stack (local)
- the second value in struct is used (u_16_value_0 works fine).
GCC v 4.3.3 also works fine on the same code.

Configuarion:
-------------
PC Windows XP with Codesourcery, Target STM32F103 ARM-Controller
>arm-none-eabi-gcc.exe -v
Using built-in specs.
COLLECT_GCC=arm-none-eabi-gcc.exe
COLLECT_LTO_WRAPPER=c:/temp/codesourcery/bin/../libexec/gcc/arm-none-eabi/4.5.1/lto-wrapper.exe
Target: arm-none-eabi
Configured with:
/scratch/julian/2010q3-release-eabi-lite/src/gcc-4.5-2010.09/configure
--build=i686-pc-linux-gnu --host=i686-mingw32 --target=arm-none-eabi
--enable-threads --disable-libmudflap --disable-libssp --disable-libstdcxx-pch
--enable-extra-sgxxlite-multilibs --with-gnu-as --with-gnu-ld
--with-specs='%{save-temps: -fverbose-asm} -D__CS_SOURCERYGXX_MAJ__=2010
-D__CS_SOURCERYGXX_MIN__=9 -D__CS_SOURCERYGXX_REV__=51
%{O2:%{!fno-remove-local-statics: -fremove-local-statics}}
%{O*:%{O|O0|O1|O2|Os:;:%{!fno-remove-local-statics: -fremove-local-statics}}}'
--enable-languages=c,c++ --disable-s
hared --enable-lto --with-newlib --with-pkgversion='Sourcery G++ Lite
2010.09-51' --with-bugurl=https://support.codesourcery.com/GNUToolchain/
--disable-nls --prefix=/opt/codesourcery --with-headers=yes
--with-sysroot=/opt/codesourcery/arm-none-eabi
--with-build-sysroot=/scratch/julian/2010q3-release-eabi-lite/install/host-i686-mingw32/arm-none-eabi
--with-libiconv-prefix=/scratch/julian/2010q3-release-eabi-lite/obj/host-libs-2010.09-51-arm-none-eabi-i686-mingw32/usr
--with-gmp=/scratch/julian/2010q3-release-eabi-lite/obj/host-libs-2010.09-51-arm-none-eabi-i686-mingw32/usr
--with-mpfr=/scratch/julian/2010q3-release-eabi-lite/obj/host-libs-2010.09-51-arm-none-eabi-i686-mingw32/usr
--with-mpc=/scratch/julian/2010q3-release-eabi-lite/obj/host-libs-2010.09-51-arm-none-eabi-i686-mingw32/usr
--with-ppl=/scratch/julian/2010q3-release-eabi-lite/obj/host-libs-2010.09-51-arm-none-eabi-i686-mingw32/usr
--with-host-libstdcxx='-static-libgcc -Wl,-Bstatic,-lst dc++,-Bdynamic -lm'
--with-cloog=/scratch/julian/2010q3-release-eabi-lite/obj/host-libs-2010.09-51-arm-none-eabi-i686-mingw32/usr
--with-libelf=/scratch/julian/2010q3-release-eabi-lite/obj/host-libs-2010.09-51-arm-none-eabi-i686-mingw32/usr
--disable-libgomp --enable-poison-system-directories
--with-build-time-tools=/scratch/julian/2010q3-release-eabi-lite/obj/tools-i686-pc-linux-gnu-2010.09-51-arm-none-eabi-i686-mingw32/arm-none-eabi/bin
--with-build-time-tools=/scratch/julian/2010q3-release-eabi-lite/obj/tools-i686-pc-linux-gnu-2010.09-51-arm-none-eabi-i686-mingw32/arm-none-eabi/bin
Thread model: single
gcc version 4.5.1 (Sourcery G++ Lite 2010.09-51)


Call-Parameters:
----------------
COLLECT_GCC_OPTIONS='-c' '-mcpu=cortex-m3' '-mthumb' '-mtune=cortex-m3'
'-mfix-cortex-m3-ldrd' '-mlong-calls' '-pedantic' '-mfpu=vfp'
'-mfloat-abi=soft' '-nostdinc' '-Os' '-DLITTLE_ENDIAN' '-v' '-gdwarf-2'
'-fmessage-length=0' '-mlittle-endian' '-fshort-enums' '-mno-thumb-interwork'
'-mstructure-size-boundary=8' '-fno-builtin' '-funsigned-bitfields'
'-Wcast-align' '-Wreturn-type' '-Wimplicit' '-Wunused' '-Wswitch'
'-Wuninitialized' '-o' 'E:\workspace_tkr\FSD-ELMA\trunk\out/SA1/ALGAac1.o'
'-D__CS_SOURCERYGXX_MAJ__=2010' '-D__CS_SOURCERYGXX_MIN__=9'
'-D__CS_SOURCERYGXX_REV__=51'
e:/toolhome/arm/codesourcery/v_4_5_1/bin/../lib/gcc/arm-none-eabi/4.5.1/../../../../arm-none-eabi/bin/as.exe
-v -EL -mcpu=cortex-m3 -mfloat-abi=soft -mfpu=vfp -meabi=5 -alhcdn -o
E:\workspace_tkr\FSD-ELMA\trunk\out/SA1/ALGAac1.o
C:\DOKUME~1\tkr\LOKALE~1\Temp\ccqr1SmQ.s
GNU assembler version 2.20.51 (arm-none-eabi) using BFD version (Sourcery G++
Lite 2010.09-51) 2.20.51.20100809

Reply via email to