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

            Bug ID: 128906
           Summary: h8300: miscompilation of busybox test applet
           Product: gcc
           Version: 16.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: wbx at openadk dot org
  Target Milestone: ---

Created attachment 66240
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=66240&action=edit
preprocessed busybox test.c

Hi,

while testing uClibc-ng 1.0.60 on my Hitachi EDOSK-2674 embedded board I found
one test, which resets the boards. The popen test:
https://github.com/wbx-github/uclibc-ng-test/blob/master/test/misc/popen.c
I narrowed it down to just this simple comparison: "[ a = a ]; echo rc=$?".

The reason seems to be a GCC 16.2.0 Bug. 
GCC used:

./toolchain_hitachi-edosk2674_uclibc-ng_flat_nommu/usr/bin/h8300-openadk-linux-uclibc-gcc
-v
Using built-in specs.
COLLECT_GCC=./toolchain_hitachi-edosk2674_uclibc-ng_flat_nommu/usr/bin/h8300-openadk-linux-uclibc-gcc
COLLECT_LTO_WRAPPER=/home/wbx/h8300/toolchain_hitachi-edosk2674_uclibc-ng_flat_nommu/usr/libexec/gcc/h8300-openadk-linux-uclibc/16.2.0/lto-wrapper
Target: h8300-openadk-linux-uclibc
Configured with:
/home/wbx/h8300/toolchain_build_hitachi-edosk2674_uclibc-ng_flat_nommu/w-gcc-16.2.0-1/gcc-16.2.0/configure
--prefix=/home/wbx/h8300/toolchain_hitachi-edosk2674_uclibc-ng_flat_nommu/usr
--with-bugurl=https://openadk.org --build=x86_64-linux-gnu
--host=x86_64-linux-gnu --target=h8300-openadk-linux-uclibc
--with-gmp=/home/wbx/h8300/host_x86_64-linux-gnu/usr
--with-mpfr=/home/wbx/h8300/host_x86_64-linux-gnu/usr --enable-__cxa_atexit
--with-system-zlib --with-gnu-ld --with-gnu-as --disable-install-libiberty
--disable-libitm --disable-libmudflap --disable-libgomp --disable-libcc1
--disable-libmpx --disable-libcilkrts --disable-libquadmath
--disable-libquadmath-support --disable-decimal-float --disable-gcov
--disable-libstdcxx-pch --disable-ppl-version-check
--disable-cloog-version-check --without-ppl --without-cloog --without-isl
--disable-werror --disable-nls --enable-obsolete --disable-lto
--disable-libsanitizer --disable-tls --disable-threads --disable-libatomic
--disable-shared --disable-libssp --disable-biarch --disable-multilib
--enable-languages=c
--with-build-sysroot='/../../target_hitachi-edosk2674_uclibc-ng_flat_nommu'
--with-sysroot='/../../target_hitachi-edosk2674_uclibc-ng_flat_nommu'
Thread model: singlegcc/config/h8300/testcompare.md
Supported LTO compression algorithms: zlib zstd
gcc version 16.2.0 (GCC) 

A workaround is to use -fno-jump-tables while compiling the code.

I have a AI generated bugfix for gcc/config/h8300/testcompare.md I can attach
if you want. Not sure what the AI policy is for a small 60 line diff.

Attached is the preprocessed busybox test applet. The binop function seems to
be the culprit of the board reset.

thanks in advance
 Waldemar

Reply via email to