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

--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> ---
The assignment operator does:

  if( nec == input.nec ) {
    if( nec == 0 || 0 == memcmp(ecs, input.ecs, nbytes()) ) return *this;
  }

  if( nec < input.nec ) {
    if( nec > 0 ) delete[] ecs;
    ecs = new cbl_enabled_exception_t[1 + input.nec];
  }
  if( input.nec > 0 ) {
    auto pend = std::copy( input.ecs, input.ecs + input.nec, ecs );
    std::fill(pend, ecs + input.nec, cbl_enabled_exception_t());
  }
  nec = input.nec;
  return *this;


Why is the new array allocated for 1 + input.nec items?
The std::fill does nothing. It copies from where the std::copy finished to ...
where the std::copy finished. Maybe it was meant to init the extra element in
the array? But why is that extra element even there?

Reply via email to