public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "davidwelch158 at hotmail dot com" <gcc-bugzilla@gcc.gnu.org>
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	[thread overview]
Message-ID: <bug-107411-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 107411
           Summary: trivial-auto-var-init=zero 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=53774&action=edit
preprocessed reproduction case

Compiling this file 

#include <cstdio>

class HostLayer 
{
public:
        int getError();

};  

void queryString(HostLayer& m_host)
{
        const auto& error = m_host.getError();
        printf("%d\n", error);
}

with the command line on x86-64 Ubuntu 22.04

g++ -Werror=uninitialized -ftrivial-auto-var-init=zero   -c OverrideLayer.cpp

and the latest gcc trunk (GCC12 is also affected) produces the warning.

OverrideLayer.cpp: In function ‘void queryString(HostLayer&)’:
OverrideLayer.cpp:12:45: error: ‘D.2933’ is used uninitialized
[-Werror=uninitialized]
   12 |         const auto& error = m_host.getError();
      |                                             ^
OverrideLayer.cpp:12:45: note: ‘D.2933’ was declared here
   12 |         const auto& error = m_host.getError();
      | 

which seems to be invalid and also doesn't identify the problem variable.

Compiling with 

/home/dw/devel/gcc/install/bin/g++ -Werror=uninitialized    -c
OverrideLayer.cpp

finishes without error.

g++ -v
Using built-in specs.
COLLECT_GCC=/home/dw/devel/gcc/install/bin/g++
COLLECT_LTO_WRAPPER=/home/dw/devel/gcc/install/libexec/gcc/x86_64-linux-gnu/13.0.0/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../configure --enable-languages=c,c++
--prefix=/home/dw/devel/gcc/install --enable-shared --enable-linker-build-id
--without-included-gettext --enable-threads=posix --enable-nls
--enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes
--with-default-libstdcxx-abi=new --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 --enable-offload-defaulted
--without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu
--host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 13.0.0 20221025 (experimental) (GCC) 

lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 22.04.1 LTS
Release:        22.04
Codename:       jammy

             reply	other threads:[~2022-10-26  9:10 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-26  9:10 davidwelch158 at hotmail dot com [this message]
2022-10-26 17:52 ` [Bug middle-end/107411] " pinskia at gcc dot gnu.org
2022-10-28 11:31 ` rguenth at gcc dot gnu.org
2022-10-28 14:15 ` qinzhao at gcc dot gnu.org
2022-11-21 15:35 ` pinskia at gcc dot gnu.org
2023-02-14  0:03 ` pinskia at gcc dot gnu.org
2023-02-15 19:21 ` qinzhao at gcc dot gnu.org
2023-02-16  7:35 ` rguenther at suse dot de
2023-02-16 14:30 ` qing.zhao at oracle dot com
2023-02-16 20:18 ` qinzhao at gcc dot gnu.org
2023-02-16 20:18 ` qinzhao at gcc dot gnu.org
2023-02-16 20:55 ` jakub at gcc dot gnu.org
2023-02-16 21:53 ` qinzhao at gcc dot gnu.org
2023-02-17  7:32 ` rguenther at suse dot de
2023-02-28 17:11 ` cvs-commit at gcc dot gnu.org
2023-02-28 17:13 ` qinzhao at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-107411-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).