public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "steveire at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/108197] New: -Wstringop-overread emitted on simple boost small_vector code
Date: Thu, 22 Dec 2022 10:10:51 +0000	[thread overview]
Message-ID: <bug-108197-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 108197
           Summary: -Wstringop-overread emitted on simple boost
                    small_vector code
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: steveire at gmail dot com
  Target Milestone: ---

```

#include <boost/container/small_vector.hpp>

struct MyThing
{
    int d0 = {};
};

void modify(boost::container::small_vector<MyThing, 10> &pp)
{
    pp.resize(1);

    pp[0].d0 = 3;
}

void foo()
{
    boost::container::small_vector<MyThing, 10> pp2;

    boost::container::small_vector<MyThing, 10> pp;

    pp.resize(1);

    pp[0].d0 = 2;

    pp2 = std::move(pp);
}
```

gives

```
/opt/compiler-explorer/libs/boost_1_80_0/boost/container/detail/copy_move_algo.hpp:184:19:
warning: 'void* __builtin_memcpy(void*, const void*, long unsigned int)'
reading between 41 and 9223372036854775804 bytes from a region of size 40
[-Wstringop-overread]
  184 |       std::memmove(dest_raw, beg_raw, sizeof(value_type)*n);
```

https://godbolt.org/z/rs3oj3YoE

Even though modify is never called, it must be in the code to reproduce the
bug.

             reply	other threads:[~2022-12-22 10:10 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-22 10:10 steveire at gmail dot com [this message]
2022-12-22 12:10 ` [Bug tree-optimization/108197] [12/13 Regression] " rguenth at gcc dot gnu.org
2022-12-24 17:21 ` steveire at gmail dot com
2023-01-13 12:49 ` rguenth at gcc dot gnu.org
2023-04-08 14:38 ` law at gcc dot gnu.org
2023-05-08 12:26 ` [Bug tree-optimization/108197] [12/13/14 " rguenth 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-108197-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).