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 via email to