https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98158
Martin Sebor <msebor at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Keywords| |diagnostic
Resolution|--- |DUPLICATE
--- Comment #2 from Martin Sebor <msebor at gcc dot gnu.org> ---
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*)&blah + offsetof (test,
b).
pr96963 already tracks the same problem so I'm going to resolve this as its
duplicate.
<bb 4> [local count: 1073741824]:
# prephitmp_60 = PHI <&MEM[(struct basic_string
*)&D.33188].D.24959._M_local_buf(2), pretmp_59(3)>
MEM[(struct basic_string *)&D.33188]._M_string_length = 0;
MEM[(char_type &)prephitmp_60] = 0;
_37 = &blah_3(D)->b; <<< address of b
vect__39.58_74 = MEM <vector(2) __int128 unsigned> [(char *
{ref-all})&D.33188 + 32B];
_39 = MEM <__int128 unsigned> [(char * {ref-all})&D.33188 + 32B];
_46 = &blah_3(D)->c;
_41 = MEM <__int128 unsigned> [(char * {ref-all})&D.33188 + 48B];
MEM <vector(2) __int128 unsigned> [(char * {ref-all})_37] = vect__39.58_74;
<<< warning: writing 2 __int128's into b with size 16
_13 = MEM[(const struct basic_string *)&D.33188]._M_dataplus._M_p;
if (&MEM[(const struct basic_string *)&D.33188].D.24959._M_local_buf != _13)
goto <bb 5>; [53.47%]
else
goto <bb 6>; [46.53%]
*** This bug has been marked as a duplicate of bug 96963 ***