[Bug middle-end/92718] [8/9/10 Regression] Bogus Wstringop-overflow in __builtin_memset() of an element of array of size 1 of struct

rlibby at gmail dot com gcc-bugzilla@gcc.gnu.org
Sat Nov 30 16:28:00 GMT 2019


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

--- Comment #3 from Ryan Libby <rlibby at gmail dot com> ---
(In reply to Martin Sebor from comment #2)
> Replacing the memset call with the assignment '*p = (struct s){ 0 };' avoids
> the warning and also results in better/optimal code.  (As suggested in
> pr36602, that would be a useful optimization independent of the warning.)

In the real code that prompted the warning, the struct has some members
which are declared const, which I believe prevents using aggregate
initialization as a workaround (or at least, it produces an error).


More information about the Gcc-bugs mailing list