https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109554
Bug ID: 109554 Summary: Compiler generates incorrect code when the function declared with returned parameterm but no 'return' in its body Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: xvladsoft at yahoo dot com Target Milestone: --- Created attachment 54883 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=54883&action=edit The source file which shows issue. Good day! First of all, thanks alot for you efforts to create so nice compiler! It is really nice: generates small and fast code! But looks like I found an issue: the compiler does not generate a 'return point' where the function is declared with not-void return parameter, but no 'return' operators in its body. Details: *** 1) Operation system: uname -a Linux XVlad-Work 4.19.0-22-amd64 #1 SMP Debian 4.19.260-1 (2022-09-29) x86_64 GNU/Linux *** 2) Compiler version (according to https://gcc.godbolt.org/ issue reproduces from 8.3.0 till the latest (12.+)): gcc -v Using built-in specs. COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/8/lto-wrapper OFFLOAD_TARGET_NAMES=nvptx-none OFFLOAD_TARGET_DEFAULT=1 Target: x86_64-linux-gnu Configured with: ../src/configure -v --with-pkgversion='Debian 8.3.0-6' --with-bugurl=file:///usr/share/doc/gcc-8/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++ --prefix=/usr --with-gcc-major-version-only --program-suffix=-8 --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 8.3.0 (Debian 8.3.0-6) *** 3) Command line to compile: gcc -O3 ./SandBox_2.cpp *** 4) Command line to execute: ./a.out 0 Observations: Please, look at the code in the attached file: - when it is compiled as: /GccBug$ gcc -O0 ./SandBox_2.cpp - program executes correctly: /GccBug$ ./a.out 0 Hello world from SandBox-2! 8.3.0 Point-A 0, 0 - *BUT* when it is compiled as: /GccBug$ gcc -O3 ./SandBox_2.cpp - program crashes: /GccBug$ ./a.out 0 Hello world from SandBox-2! 8.3.0 Point-A 0, 0 Point-B 1, 0 Segmentation fault <<<!!!!!!! Best regards, Vladimir.