https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94734
Bug ID: 94734 Summary: Program crashes when compiled with GCC 10 Product: gcc Version: 10.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: john+gcc at hogberg dot online Target Milestone: --- Created attachment 48361 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=48361&action=edit Test case program The attached program crashes when it has been compiled with GCC 10 and -O2. With -O3 or -Os it returns an incorrect value instead. There are no warnings with `-Wall -Wextra` or `-fanalyzer`, and strangely enough `-fsanitize=undefined` hides the crash without reporting any errors. -fno-aggressive-loop-optimizations also makes the crash go away which made me suspect that the code is wrong somehow, but `frama-c` insists that it's correct and should always return 0. If there's a bug in there, I'm not seeing it. :( Steps to reproduce: ---- $ gcc -O2 test.c -o bug $ ./bug Segmentation fault (core dumped) ---- GCC version: ---- $ gcc -v Using built-in specs. COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc/x86_64-pc-linux-gnu/10.0.1/lto-wrapper Target: x86_64-pc-linux-gnu Configured with: ./configure Thread model: posix Supported LTO compression algorithms: zlib gcc version 10.0.1 20200423 (experimental) (GCC) ---- It appears to work fine with GCC 7, I tested it with: ---- $ gcc-7 -v Using built-in specs. COLLECT_GCC=gcc-7 COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/7/lto-wrapper OFFLOAD_TARGET_NAMES=nvptx-none OFFLOAD_TARGET_DEFAULT=1 Target: x86_64-linux-gnu Configured with: ../src/configure -v --with-pkgversion='Ubuntu 7.5.0-3ubuntu1~18.04' --with-bugurl=file:///usr/share/doc/gcc-7/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++ --prefix=/usr --with-gcc-major-version-only --program-suffix=-7 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-bootstrap --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-libmpx --enable-plugin --enable-default-pie --with-system-zlib --with-target-system-zlib --enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu Thread model: posix gcc version 7.5.0 (Ubuntu 7.5.0-3ubuntu1~18.04) ----