[Bug rtl-optimization/83124] New: wrong code on arm-linux-gnueabi-gcc with -O3 optimization

yangyibiao at nju dot edu.cn gcc-bugzilla@gcc.gnu.org
Thu Nov 23 08:37:00 GMT 2017


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

            Bug ID: 83124
           Summary: wrong code on arm-linux-gnueabi-gcc with -O3
                    optimization
           Product: gcc
           Version: 5.4.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: rtl-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: yangyibiao at nju dot edu.cn
  Target Milestone: ---

this wrong code occurred while optimization flag "-O3" was used in
arm-linux-gnueabi-gcc

$ arm-linux-gnueabi-gcc -v
Using built-in specs.
COLLECT_GCC=arm-linux-gnueabi-gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc-cross/arm-linux-gnueabi/5/lto-wrapper
Target: arm-linux-gnueabi
Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro
5.4.0-6ubuntu1~16.04.4' --with-bugurl=file:///usr/share/doc/gcc-5/README.Bugs
--enable-languages=c,ada,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr
--program-suffix=-5 --enable-shared --enable-linker-build-id
--libexecdir=/usr/lib --without-included-gettext --enable-threads=posix
--libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu
--enable-libstdcxx-debug --enable-libstdcxx-time=yes
--with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-libitm
--disable-libquadmath --enable-plugin --with-system-zlib
--disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo
--with-java-home=/usr/lib/jvm/java-1.5.0-gcj-5-armel-cross/jre
--enable-java-home
--with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-5-armel-cross
--with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-5-armel-cross
--with-arch-directory=arm --with-ecj-jar=/usr/share/java/eclipse-ecj.jar
--disable-libgcj --enable-objc-gc --enable-multiarch --enable-multilib
--disable-sjlj-exceptions --with-arch=armv5t --with-float=soft --disable-werror
--enable-multilib --enable-checking=release --build=x86_64-linux-gnu
--host=x86_64-linux-gnu --target=arm-linux-gnueabi
--program-prefix=arm-linux-gnueabi- --includedir=/usr/arm-linux-gnueabi/include
Thread model: posix
gcc version 5.4.0 20160609 (Ubuntu/Linaro 5.4.0-6ubuntu1~16.04.4)

$ cat small.c
union {
  unsigned short a
} b = {1};
*c = &b;
long *d = &b;
main() {
  *d = 4294967295;
  *c |= 55868;
  printf("%X\n", b.a);
}

$ arm-linux-gnueabi-gcc -static -w -O3 small.c; ./a.out
DA3D

$ arm-linux-gnueabi-gcc -static -w -O0 small.c; ./a.out
FFFF

$ gcc -static -w -m32 -O0 small.c; ./a.out
FFFF

$ clang -static -w -m32 -O0 small.c; ./a.out
FFFF


More information about the Gcc-bugs mailing list