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

--- Comment #1 from Martin Sebor <msebor at gcc dot gnu.org> ---
Actually, what I was really after is trying to see if the analyzer would print
the conditionals involved in the subscript expressions.  But in the simple test
case in comment #0 there are no conditionals.  They are here:

int f (int i, int j)
{
  int a[3];
  a[0] = 1;
  a[1] = 2;

  if (i < 1 || 3 < i) i = 1;
  if (j < 1 || 5 < j) j = 1;
  return a[i + j];
}

but it doesn't print them even at -O2 when it does warn:

z.c: In function ‘f’:
z.c:9:11: warning: use of uninitialized value ‘a[<unknown>]’ [CWE-457]
[-Wanalyzer-use-of-uninitialized-value]
    9 |   return a[i + j];
      |          ~^~~~~~~
  ‘f’: event 1
    |
    |    9 |   return a[i + j];
    |      |          ~^~~~~~~
    |      |           |
    |      |           (1) use of uninitialized value ‘a[<unknown>]’ here
    |

Reply via email to