[Bug tree-optimization/126737] New: [14/15/16/17 Regression] -Wmaybe-uninitialized false positive under -O2

"gnu.ojxq8 at dralias dot com via Gcc-bugs" <[email protected]>
Newsgroups gmane.comp.gcc.bugs
Message-ID <[email protected]/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=126737

            Bug ID: 126737
           Summary: [14/15/16/17 Regression]  -Wmaybe-uninitialized false
                    positive under -O2
           Product: gcc
           Version: 17.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: gnu.ojxq8 at dralias dot com
  Target Milestone: ---

The repro is a small function to pad some input buffer.

Flags to repro:

-O2 -g -std=c++11 -Wall -Wextra -Warray-bounds=2

Code to repro:

#include <algorithm>
#include <string>
#include <vector>
void consume(const char*);
void make_buffer(const std::string& input, std::size_t extra_size)
{
    if (input.size() >= std::string::npos - extra_size) return;
    std::vector<char> buffer(extra_size + input.size() + 1);
    std::copy(input.begin(), input.end(), buffer.data() + 1);
    consume(buffer.data());
}


https://godbolt.org/z/EoadcbzMr
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.