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

--- Comment #12 from Tomasz KamiƄski <tkaminsk at gcc dot gnu.org> ---
> I like the suggestion to use additional elements in the vector. It's hacky, 
> but we have no choice at this point.

Unfortunately, the implementation of piecewise_constant_distribution is using
the size of _M_cp inside implementation of operator():
```
auto __pos = std::lower_bound(__param._M_cp.begin(),
                              __param._M_cp.end(), __p);
```
So this will break if we expand the size of _M_cp vector. We could make it even
more hacky, by storing the elements in unused capacity without changing the
size, but then
bytes will not be preserved when copying (only size elements are copied), and
will make detection unreliable.

To explain the later, as _M_cp is always reserved in initialized, we could use
check for _M_capacity() > _M_size (or equal to required size). However, this
will lead to false-positives where param_types are copy assigned. In that case,
if the capacity if assigment target capacity is sufficient, the allocation will
be preserved.

Reply via email to