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

            Bug ID: 116454
           Summary: Under certain conditions, gcc produces an extra "addq
                    $8, 40(%rsp)" instruction overfreeing the stack.
           Product: gcc
           Version: 14.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: Liam_Kerrigan at outlook dot com
  Target Milestone: ---

Created attachment 58973
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=58973&action=edit
Compiling main.c as described above produces an executable that returns 1, but
should return 0.

gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=C:/w64devkit/bin/../libexec/gcc/x86_64-w64-mingw32/14.2.0/lto-wrapper.exe
Target: x86_64-w64-mingw32
Configured with: /gcc-14.2.0/configure --prefix=/w64devkit
--with-sysroot=/w64devkit/x86_64-w64-mingw32
--with-native-system-header-dir=/include --target=x86_64-w64-mingw32
--host=x86_64-w64-mingw32 --enable-static --disable-shared --with-pic
--with-gmp-include=/deps/include --with-gmp-lib=/deps/lib
--with-mpc-include=/deps/include --with-mpc-lib=/deps/lib
--with-mpfr-include=/deps/include --with-mpfr-lib=/deps/lib
--enable-languages=c,c++,fortran --enable-libgomp --enable-threads=posix
--enable-version-specific-runtime-libs --disable-dependency-tracking
--disable-lto --disable-multilib --disable-nls --disable-win32-registry
--enable-mingw-wildcard CFLAGS_FOR_TARGET=-Os CXXFLAGS_FOR_TARGET=-Os
LDFLAGS_FOR_TARGET=-s CFLAGS=-Os CXXFLAGS=-Os LDFLAGS=-s
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 14.2.0 (GCC)

The complete command line that triggers the bug:
gcc -ffast-math main.c -o e.exe

Potentially helpful notes:
The bug does not occur if the line "*++ptr * 1j;" is replaced with "++ptr; *ptr
* 1j;" in main.c
If that line is replaced as such, the only difference in the assembly generated
by gcc with the -S is that one of the two consecutive "addq $8, 40(%rsp)"
instructions is removed.

Reply via email to