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

--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Another example of how the optimization is non-conforming, as I just
rediscovered:

#include <algorithm>
#include <assert.h>

struct X {
  int i = 0;

  X& operator=(int ii)
  {
    i = ii + 1;
    return *this;
  }
};

int main()
{
  X x[2];
  std::fill_n(x, 2, x[0].i);
  assert(x[1].i == 2);
}

Reply via email to