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

            Bug ID: 116885
           Summary: Wrong functionality of vararg causes malfunction or
                    crashes
           Product: gcc
           Version: 14.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: JaFojtik at seznam dot cz
  Target Milestone: ---

Created attachment 59221
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=59221&action=edit
Minimal testcase with makefile

There is something wrong in vararg implementation. All versions before 14.0 did
not have this issue. It manifests 3 different behaviors on different platforms.
Sometimes it crashes, sometimes it works bad and sometimes it works OK.

Even when it crashes, some arguments are processed correctly.

I have attempted to create minimal testcase without amalgamise everything into
one unreadable file. This mintest still could be built on multiple platforms.

jara@cfarm421:~/mintest$ make
gcc -I./ -Wall -g -O2  -c struct.c  -o struct.o
gcc -I./ -Wall -g -O2  -c mintest.c  -o mintest.o
gcc -lm -o mintest struct.o mintest.o

I have also tested option -O0 without any positive effect.

************************************************************************

jara@cfarm421:~/mintest$ ./mintest

<<<struct>>> (c)1998-2024 Jaroslav Fojtik
                 This program tests the struct.c library
***LO_ENDIAN defined***
***NATIVE access***
 Testing struct manipulation
Segmentation fault
jara@cfarm421:~/mintest$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-linux-gnu/14/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none:amdgcn-amdhsa
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Debian 14.2.0-3'
--with-bugurl=file:///usr/share/doc/gcc-14/README.Bugs
--enable-languages=c,ada,c++,go,d,fortran,objc,obj-c++,m2,rust --prefix=/usr
--with-gcc-major-version-only --program-suffix=-14
--program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id
--libexecdir=/usr/libexec --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-libstdcxx-backtrace
--enable-gnu-unique-object --disable-vtable-verify --enable-plugin
--enable-default-pie --with-system-zlib --enable-libphobos-checking=release
--with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch
--disable-werror --enable-cet --with-arch-32=i686 --with-abi=m64
--with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic
--enable-offload-targets=nvptx-none=/build/reproducible-path/gcc-14-14.2.0/debian/tmp-nvptx/usr,amdgcn-amdhsa=/build/reproducible-path/gcc-14-14.2.0/debian/tmp-gcn/usr
--enable-offload-defaulted --without-cuda-driver --enable-checking=release
--build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
--with-build-config=bootstrap-lto-lean --enable-link-serialization=2
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 14.2.0 (Debian 14.2.0-3)


************************************************************************
[jara@cfarm420 mintest]$ ./mintest

<<<struct>>> (c)1998-2024 Jaroslav Fojtik
                 This program tests the struct.c library
***LO_ENDIAN defined***
***NATIVE access***
 Testing struct manipulation
Wrong value read from struct SU.TileCompression 216, expected 2
Wrong value read from struct SU.TileByteCounts 0, expected 2077093650
Wrong value read from struct SU.xRasMin 0.000000, expected -100.500000
Wrong value read from struct SU.Dummy "@â–’â–’â–’Lq", expected "Hello word from
struct test".

[jara@cfarm420 ~]$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-pc-linux-gnu/14.2.1/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /build/gcc/src/gcc/configure
--enable-languages=ada,c,c++,d,fortran,go,lto,m2,objc,obj-c++,rust
--enable-bootstrap --prefix=/usr --libdir=/usr/lib --libexecdir=/usr/lib
--mandir=/usr/share/man --infodir=/usr/share/info
--with-bugurl=https://gitlab.archlinux.org/archlinux/packaging/packages/gcc/-/issues
--with-build-config=bootstrap-lto --with-linker-hash-style=gnu
--with-system-zlib --enable-__cxa_atexit --enable-cet=auto
--enable-checking=release --enable-clocale=gnu --enable-default-pie
--enable-default-ssp --enable-gnu-indirect-function --enable-gnu-unique-object
--enable-libstdcxx-backtrace --enable-link-serialization=1
--enable-linker-build-id --enable-lto --enable-multilib --enable-plugin
--enable-shared --enable-threads=posix --disable-libssp --disable-libstdcxx-pch
--disable-werror
Thread model: posix
Supported LTO compression algorithms: zlib zstd

*************************************************************************

$ ./mintest

<<<struct>>> (c)1998-2024 Jaroslav Fojtik
                 This program tests the struct.c library
***LO_ENDIAN defined***
***NATIVE access***
 Testing struct manipulation
 .............. Test passed OK ..............

JFT@DESKTOP-E4MGIUU MINGW64 /o/temp/mintest
$ gcc -v
Using built-in specs.
COLLECT_GCC=O:\programs\msys64\mingw64\bin\gcc.exe
COLLECT_LTO_WRAPPER=O:/programs/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/lto-wrapper.exe
Target: x86_64-w64-mingw32
Configured with: ../gcc-13.2.0/configure --prefix=/mingw64
--with-local-prefix=/mingw64/local --build=x86_64-w64-mingw32
--host=x86_64-w64-m
ingw32 --target=x86_64-w64-mingw32
--with-native-system-header-dir=/mingw64/include --libexecdir=/mingw64/lib
--enable-bootstrap --enable-ch
ecking=release --with-arch=nocona --with-tune=generic
--enable-languages=c,lto,c++,fortran,ada,objc,obj-c++,jit --enable-shared
--enable-sta
tic --enable-libatomic --enable-threads=posix --enable-graphite
--enable-fully-dynamic-string --enable-libstdcxx-filesystem-ts --enable-libs
tdcxx-time --disable-libstdcxx-pch --enable-lto --enable-libgomp
--disable-libssp --disable-multilib --disable-rpath --disable-win32-registr
y --disable-nls --disable-werror --disable-symvers --with-libiconv
--with-system-zlib --with-gmp=/mingw64 --with-mpfr=/mingw64 --with-mpc=/m
ingw64 --with-isl=/mingw64 --with-pkgversion='Rev3, Built by MSYS2 project'
--with-bugurl=https://github.com/msys2/MINGW-packages/issues --w
ith-gnu-as --with-gnu-ld --disable-libstdcxx-debug
--with-boot-ldflags=-static-libstdc++ --with-stage1-ldflags=-static-libstdc++
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 13.2.0 (Rev3, Built by MSYS2 project)

Reply via email to