https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70335

            Bug ID: 70335
           Summary: tree-switch-conversion uses erroneous sign extension
                    of data loaded from CSWTCH
           Product: gcc
           Version: 4.9.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jmargetts at ocz dot com
  Target Milestone: ---

Created attachment 38044
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=38044&action=edit
Failing test case

The attached test case fails due to sign extension of the int 128 being packed
into a byte in the compiler generated CSWTCH table, and then erroneously sign
extended when it is loaded at run-time.

In the failing case vb == 0xFFFFFF80, where it should be 0x00000080

Configuration:

Target: arm-none-eabi
Configured with: ../gcc-4.9.3/configure --target=arm-none-eabi
--prefix=/usr/julien/toolchain_build_NO_MODS/install-4.9.3
--enable-languages=c,c++ --with-newlib --with-gnu-as --with-gnu-ld
--disable-nls --disable-shared --disable-multilib --disable-threads
--with-headers=newlib/libc/include --disable-libssp --disable-libstdcxx-pch
--disable-libmudflap --disable-libgomp --disable-libunwind --with-system-zlib
--disable-newlib-supplied-syscalls
Thread model: single
gcc version 4.9.3 (GCC)

Invocation:

arm-none-eabi-gcc -Wall -Wextra -O2 -march=armv4 -o test.elf test.c 

Workaround:
Explicitly disabling the feature with -fno-tree-switch-conversion produces a
working executable

NOTE: This test case is based on pr45830.c, which also fails in this
configuration

Reply via email to