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

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

            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 <string>
#include <vector>
#include <cstring>

struct string_piece {
  const char * begin_ = nullptr;
  const char * end_   = nullptr;
  std::string str() const { return std::string(begin_, end_); }

  string_piece(const char* string) : begin_(string), end_(string) {
    end_ += strlen(string);
  }

  string_piece(const string_piece& other) {
    begin_ = other.begin_;
    end_ = 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<Z> input_files;
  const std::string current_entry_point_name("main");
  const string_piece arg = 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=c++11  -o main.cc.o -c glslc/src/main.cc

In file included from /<<NIX>>/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_data()
const [with _CharT = char; _Traits = std::char_traits<char>; _Alloc =
std::allocator<char>]',
    inlined from 'bool std::__cxx11::basic_string<_CharT, _Traits,
_Alloc>::_M_is_local() const [with _CharT = char; _Traits =
std::char_traits<char>; _Alloc = std::allocator<char>]' at
/<<NIX>>/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 = char; _Traits = std::char_traits<char>;
_Alloc = std::allocator<char>]' at
/<<NIX>>/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 = char; _Traits = std::char_traits<char>;
_Alloc = std::allocator<char>]' at
/<<NIX>>/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:
/<<NIX>>/gcc-12.0.0/include/c++/12.0.0/bits/basic_string.h:235:28: error:
'<unnamed>.Z::name.std::__cxx11::basic_string<char>::_M_dataplus.std::__cxx11::basic_string<char>::_Alloc_hider::_M_p'
may be used uninitialized [-Werror=maybe-uninitialized]
  235 |       { return _M_dataplus._M_p; }
      |                            ^~~~
glslc/src/main.cc: In function 'int main(int, char**)':
glslc/src/main.cc:32:3: note: '<anonymous>' declared here
   32 |   });
      |   ^
cc1plus: all warnings being treated as errors

$ g++-12.0.0 -v
Using built-in specs.
COLLECT_GCC=/<<NIX>>/gcc-12.0.0/bin/g++
COLLECT_LTO_WRAPPER=/<<NIX>>/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)

             reply	other threads:[~2022-01-11 22:18 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-11 22:18 slyfox at gcc dot gnu.org [this message]
2022-01-11 22:31 ` [Bug c++/103984] " pinskia at gcc dot gnu.org
2022-01-11 22:34 ` pinskia at gcc dot gnu.org
2022-01-12  7:39 ` rguenth at gcc dot gnu.org
2022-01-12  8:29 ` jakub at gcc dot gnu.org
2022-01-26 17:48 ` [Bug c++/103984] [12 regression] Possible maybe-uninitialized false positive on shaderc-2021.0 since r12-6329 jason at gcc dot gnu.org
2022-01-26 18:35 ` jason at gcc dot gnu.org
2022-01-26 19:03 ` jason at gcc dot gnu.org
2022-01-26 19:25 ` [Bug middle-end/103984] " jason at gcc dot gnu.org
2022-03-01 15:04 ` marxin at gcc dot gnu.org
2022-03-01 15:26 ` [Bug middle-end/103984] [12 regression] Possible maybe-uninitialized false positive on shaderc-2021.0 since r12-6329-g4f6bc28fc7dd86bd cvs-commit at gcc dot gnu.org
2022-03-15 14:22 ` jakub at gcc dot gnu.org
2022-03-15 15:06 ` jakub at gcc dot gnu.org
2022-03-15 15:16 ` jakub at gcc dot gnu.org
2022-03-15 15:55 ` jakub at gcc dot gnu.org
2022-03-15 16:55 ` jakub at gcc dot gnu.org
2022-03-15 18:00 ` jakub at gcc dot gnu.org
2022-03-16  8:47 ` jakub at gcc dot gnu.org
2022-03-16  8:58 ` jakub at gcc dot gnu.org
2022-03-17  8:26 ` cvs-commit at gcc dot gnu.org
2022-03-17  8:46 ` jakub 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-103984-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).