public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/107411] New: trivial-auto-var-init=zero invalid uninitialized variable warning
@ 2022-10-26  9:10 davidwelch158 at hotmail dot com
  2022-10-26 17:52 ` [Bug middle-end/107411] " pinskia at gcc dot gnu.org
                   ` (14 more replies)
  0 siblings, 15 replies; 16+ messages in thread
From: davidwelch158 at hotmail dot com @ 2022-10-26  9:10 UTC (permalink / raw)
  To: gcc-bugs

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

^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2023-02-28 17:13 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-26  9:10 [Bug c++/107411] New: trivial-auto-var-init=zero invalid uninitialized variable warning davidwelch158 at hotmail dot com
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

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).