https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80944
--- Comment #3 from Martin Sebor ---
Good point! It never occurred to me. That explains why no compiler does it.
That suggests that the optimization opportunity is up to the user. I.e., a
class like std::string could optimize this case by
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80944
Richard Biener changed:
What|Removed |Added
Status|UNCONFIRMED |RESOLVED
Resolution|---
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80944
--- Comment #1 from Marc Glisse ---
(In reply to Martin Sebor from comment #0)
> struct S { char *s; unsigned n; };
>
> void f (struct S *s)
> {
> __builtin_memset (s->s, 0, s->n);
> __builtin_free (s->s);
> __builtin_memset (s, 0, sizeof