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

--- Comment #7 from qinzhao at gcc dot gnu.org ---
(In reply to Kees Cook from comment #6)
> (In reply to qinzhao from comment #5)
> > adding __attribute__ ((noreturn)) to the routine "warn" can eliminate the
> > false positive warning.
> 
> But it does return... it's not an assert.

***the original code is:

if (index >= 4)
  warn ();
*regs = sg->vals[index];

if the routine "warn" does return, then
it's reasonable to convert the above original code to:

***the transformed code:

if (index >= 4)
  {
    warn ();
    *regs = sg->vals[index];   /* here, index >= 4, therefore, out-of-bound */
  }
else
  *regs = sg->vals[index];

Reply via email to