https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98158
Martin Sebor changed:
What|Removed |Added
Status|NEW |RESOLVED
Keywords||diagnostic
Resolution|--- |DUPLICATE
--- Comment #2 from Martin Sebor ---
The warning works as designed. It's based on the GIMPLE below
(-fdump-tree-strlen) where GCC synthesizes a single store to clear the two
consecutive members. There's code in the warning that tries to deal with this
but a better solution would be to emit IL that c orresponds to valid code
instead of IL that's indistinguishable from a buffer overflow. I.e., instead
of writing the 32 bytes into b write them into (char*) + offsetof (test,
b).
pr96963 already tracks the same problem so I'm going to resolve this as its
duplicate.
[local count: 1073741824]:
# prephitmp_60 = PHI <[(struct basic_string
*)].D.24959._M_local_buf(2), pretmp_59(3)>
MEM[(struct basic_string *)]._M_string_length = 0;
MEM[(char_type &)prephitmp_60] = 0;
_37 = _3(D)->b; <<< address of b
vect__39.58_74 = MEM [(char *
{ref-all}) + 32B];
_39 = MEM <__int128 unsigned> [(char * {ref-all}) + 32B];
_46 = _3(D)->c;
_41 = MEM <__int128 unsigned> [(char * {ref-all}) + 48B];
MEM [(char * {ref-all})_37] = vect__39.58_74;
<<< warning: writing 2 __int128's into b with size 16
_13 = MEM[(const struct basic_string *)]._M_dataplus._M_p;
if ([(const struct basic_string *)].D.24959._M_local_buf != _13)
goto ; [53.47%]
else
goto ; [46.53%]
*** This bug has been marked as a duplicate of bug 96963 ***