From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 3783C3858029; Tue, 11 Jan 2022 22:18:29 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3783C3858029 From: "slyfox at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/103984] New: [12 regression] Possible maybe-uninitialized false positive on shaderc-2021.0 Date: Tue, 11 Jan 2022 22:18: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: 12.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: slyfox at gcc dot gnu.org 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 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 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 Jan 2022 22:18:29 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D103984 Bug ID: 103984 Summary: [12 regression] Possible maybe-uninitialized false positive on shaderc-2021.0 Product: gcc Version: 12.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: slyfox at gcc dot gnu.org Target Milestone: --- Noticed new warning on shaderc-2021.0 which uses -Werror. Last week's gcc-12 snapshot did not flag it as a warning. Here is the extracted example: // $ cat glslc/src/main.cc #include #include #include struct string_piece { const char * begin_ =3D nullptr; const char * end_ =3D nullptr; std::string str() const { return std::string(begin_, end_); } string_piece(const char* string) : begin_(string), end_(string) { end_ +=3D strlen(string); } string_piece(const string_piece& other) { begin_ =3D other.begin_; end_ =3D other.end_; } }; struct Z { std::string name; int stage; }; extern int to_stage(string_piece file_name); int main(int argc, char** argv) { std::vector input_files; const std::string current_entry_point_name("main"); const string_piece arg =3D argv[0]; input_files.emplace_back(Z{ arg.str(), // what is the lifetime of this temporary? to_stage(arg), // why does this constructor matter? }); return 0; } $ g++-12.0.0 -O1 -Wall -Werror -std=3Dc++11 -o main.cc.o -c glslc/src/main= .cc In file included from /<>/gcc-12.0.0/include/c++/12.0.0/string:53, from glslc/src/main.cc:1: In member function 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::pointer std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::_M_da= ta() const [with _CharT =3D char; _Traits =3D std::char_traits; _Alloc =3D std::allocator]', inlined from 'bool std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::_M_is_local() const [with _CharT =3D char; _Traits =3D std::char_traits; _Alloc =3D std::allocator]' at /<>/gcc-12.0.0/include/c++/12.0.0/bits/basic_string.h:275:23, inlined from 'void std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::_M_dispose() [with _CharT =3D char; _Traits =3D std::char_traits; _Alloc =3D std::allocator]' at /<>/gcc-12.0.0/include/c++/12.0.0/bits/basic_string.h:286:18, inlined from 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::~basic_string() [with _CharT =3D char; _Traits =3D std::char_trait= s; _Alloc =3D std::allocator]' at /<>/gcc-12.0.0/include/c++/12.0.0/bits/basic_string.h:793:19, inlined from 'int main(int, char**)' at glslc/src/main.cc:35:1: /<>/gcc-12.0.0/include/c++/12.0.0/bits/basic_string.h:235:28: error: '.Z::name.std::__cxx11::basic_string::_M_dataplus.std::__cxx= 11::basic_string::_Alloc_hider::_M_p' may be used uninitialized [-Werror=3Dmaybe-uninitialized] 235 | { return _M_dataplus._M_p; } | ^~~~ glslc/src/main.cc: In function 'int main(int, char**)': glslc/src/main.cc:32:3: note: '' declared here 32 | }); | ^ cc1plus: all warnings being treated as errors $ g++-12.0.0 -v Using built-in specs. COLLECT_GCC=3D/<>/gcc-12.0.0/bin/g++ COLLECT_LTO_WRAPPER=3D/<>/gcc-12.0.0/libexec/gcc/x86_64-unknown-linux-= gnu/12.0.0/lto-wrapper Target: x86_64-unknown-linux-gnu Configured with: Thread model: posix Supported LTO compression algorithms: zlib gcc version 12.0.0 20220109 (experimental) (GCC)=