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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |WAITING
   Last reconfirmed|                            |2022-08-29
     Ever confirmed|0                           |1

--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
GCC diagnoses

(gdb) p debug_gimple_stmt (call)
# .MEM_11 = VDEF <.MEM_5(D)>
memset (8B, 255, 8);

which it carefully isolated:

<bb 2> [local count: 1073741824]:
_1 = ary_6(D)->objcnt;
if (_1 != 0)
  goto <bb 3>; [100.00%]
else
  goto <bb 4>; [0.00%]

<bb 3> [local count: 536870913]:
_2 = ary_6(D)->objary;
_3 = &_2->field1;
memset (_3, 255, 8);
_2->field0 = 0;
return;

<bb 4> [count: 0]:
memset (8B, 255, 8);
MEM[(struct obj_t *)0B].field0 ={v} 0;
__builtin_trap ();

that is, your code, if ary->objcnt == 0, calls memset (&NULL->field1, 0xff, 8).

But maybe you over-reduced the testcase?  If not then GCC is certainly
correct here and your code is bogus.

Reply via email to