From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 9DE8D3857837; Wed, 26 Oct 2022 09:10:13 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9DE8D3857837 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1666775413; bh=ZjXs6rLY+OwQxy4Imj96xT/cSz0KdPc/zn5bAiQfmgY=; h=From:To:Subject:Date:From; b=rtwIZhToZLe1KzsA8SDrdZ1eho281kKwIEdS7Ge46V++8PtJOGET7ZLFYw+9+z6/6 rVsoKx8m3R9JZLbgOsa05bqSVI7+0bLh5FlyZN+b3Q1YKbAByd2xYkD0okkLKKuOGU ipZHhua2TtIDX4C/7g0Q1MpEWBbTt8t4a4PoA1Bc= From: "davidwelch158 at hotmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/107411] New: trivial-auto-var-init=zero invalid uninitialized variable warning Date: Wed, 26 Oct 2022 09:10:12 +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: 13.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: davidwelch158 at hotmail 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=3D107411 Bug ID: 107411 Summary: trivial-auto-var-init=3Dzero invalid uninitialized variable warning Product: gcc Version: 13.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: davidwelch158 at hotmail dot com Target Milestone: --- Created attachment 53774 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=3D53774&action=3Dedit preprocessed reproduction case Compiling this file=20 #include class HostLayer=20 { public: int getError(); };=20=20 void queryString(HostLayer& m_host) { const auto& error =3D m_host.getError(); printf("%d\n", error); } with the command line on x86-64 Ubuntu 22.04 g++ -Werror=3Duninitialized -ftrivial-auto-var-init=3Dzero -c OverrideLay= er.cpp and the latest gcc trunk (GCC12 is also affected) produces the warning. OverrideLayer.cpp: In function =E2=80=98void queryString(HostLayer&)=E2=80= =99: OverrideLayer.cpp:12:45: error: =E2=80=98D.2933=E2=80=99 is used uninitiali= zed [-Werror=3Duninitialized] 12 | const auto& error =3D m_host.getError(); | ^ OverrideLayer.cpp:12:45: note: =E2=80=98D.2933=E2=80=99 was declared here 12 | const auto& error =3D m_host.getError(); |=20 which seems to be invalid and also doesn't identify the problem variable. Compiling with=20 /home/dw/devel/gcc/install/bin/g++ -Werror=3Duninitialized -c OverrideLayer.cpp finishes without error. g++ -v Using built-in specs. COLLECT_GCC=3D/home/dw/devel/gcc/install/bin/g++ COLLECT_LTO_WRAPPER=3D/home/dw/devel/gcc/install/libexec/gcc/x86_64-linux-g= nu/13.0.0/lto-wrapper Target: x86_64-linux-gnu Configured with: ../configure --enable-languages=3Dc,c++ --prefix=3D/home/dw/devel/gcc/install --enable-shared --enable-linker-build= -id --without-included-gettext --enable-threads=3Dposix --enable-nls --enable-clocale=3Dgnu --enable-libstdcxx-debug --enable-libstdcxx-time=3Dy= es --with-default-libstdcxx-abi=3Dnew --enable-gnu-unique-object --disable-vtable-verify --enable-plugin --enable-default-pie --with-system-= zlib --enable-libphobos-checking=3Drelease --with-target-system-zlib=3Dauto --enable-objc-gc=3Dauto --enable-multiarch --disable-werror --enable-cet --with-arch-32=3Di686 --with-abi=3Dm64 --enable-offload-defaulted --without-cuda-driver --enable-checking=3Drelease --build=3Dx86_64-linux-gnu --host=3Dx86_64-linux-gnu --target=3Dx86_64-linux-gnu Thread model: posix Supported LTO compression algorithms: zlib zstd gcc version 13.0.0 20221025 (experimental) (GCC)=20 lsb_release -a No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 22.04.1 LTS Release: 22.04 Codename: jammy=