From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 462B53858D1E; Wed, 19 Apr 2023 11:47:30 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 462B53858D1E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1681904850; bh=pxJqHja4/lxeNP0eTTr/QcZ6wishMqiUc/RpIf4EgDw=; h=From:To:Subject:Date:From; b=qJ2JOICemgXVgUXevZ4H4IN03GhdhYlgmbic3SLhaYdoglofqAYgCOttunCpncvEP XCYwY2EMvPkDoYSFlrnDyjEhxvxZ6JprJB95G8tNXCrN9CSDvDoNmR2q3Hj3bjFtMb ilOfZyjr0FF8uDlpiis9dZj+te7lhr7tehaoKYdc= From: "xvladsoft at yahoo dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/109554] New: Compiler generates incorrect code when the function declared with returned parameterm but no 'return' in its body Date: Wed, 19 Apr 2023 11:47:29 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c X-Bugzilla-Version: unknown X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: xvladsoft at yahoo dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone attachments.created Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D109554 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=3D54883&action=3Dedit 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=3Dgcc COLLECT_LTO_WRAPPER=3D/usr/lib/gcc/x86_64-linux-gnu/8/lto-wrapper OFFLOAD_TARGET_NAMES=3Dnvptx-none OFFLOAD_TARGET_DEFAULT=3D1 Target: x86_64-linux-gnu Configured with: ../src/configure -v --with-pkgversion=3D'Debian 8.3.0-6' --with-bugurl=3Dfile:///usr/share/doc/gcc-8/README.Bugs --enable-languages=3Dc,ada,c++,go,brig,d,fortran,objc,obj-c++ --prefix=3D/u= sr --with-gcc-major-version-only --program-suffix=3D-8 --program-prefix=3Dx86_64-linux-gnu- --enable-shared --enable-linker-build-= id --libexecdir=3D/usr/lib --without-included-gettext --enable-threads=3Dposix --libdir=3D/usr/lib --enable-nls --enable-bootstrap --enable-clocale=3Dgnu --enable-libstdcxx-debug --enable-libstdcxx-time=3Dyes --with-default-libstdcxx-abi=3Dnew --enable-gnu-unique-object --disable-vtable-verify --enable-libmpx --enable-plugin --enable-default-pie --with-system-zlib --with-target-system-zlib --enable-objc-gc=3Dauto --enable-multiarch --disable-werror --with-arch-32=3Di686 --with-abi=3Dm64 --with-multilib-list=3Dm32,m64,mx32 --enable-multilib --with-tune=3Dgeneric --enable-offload-targets=3Dnvptx-none --without-cuda-driver --enable-checking=3Drelease --build=3Dx86_64-linux-gnu --host=3Dx86_64-linu= x-gnu --target=3Dx86_64-linux-gnu Thread model: posix gcc version 8.3.0 (Debian 8.3.0-6)=20 *** 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:=20 - 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 <<