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

--- Comment #2 from Martin Sebor <msebor at gcc dot gnu.org> ---
The null pointer instrumentation added by the sanitizer causes GCC trouble. 
We've seen it with the original implementation of the -Wnonnull warning, it
still causes null warnings out of builtin-ssa-sprintf.c in bootstrap-ubsan, and
it looks like it's also (indirectly) behind this warning.  In this case I see
no reason why the sanitizer adds the null pointer check for buffer when there's
no way for it to be null.  There should be a way to avoid it in the basic case,
though I suspect the problem might be more general in nature (and why Richard
argues for merging some of these passes with VRP).

  <bb 5> [0.00%]:
  if (&buffer == 0B)
    goto <bb 9>; [0.04%]
  else
    goto <bb 8>; [99.96%]

  <bb 9> [0.00%]:
  __builtin___ubsan_handle_nonnull_arg (&*.Lubsan_data0);

I think the sprintf-return-value pass is before vrp2 because it sets range info
that vrp2 then makes use of.  The test below (extracted from the test suite)
fails when the pass is moved after vrp2.

void f (const char *s)
{
  int n = __builtin_snprintf (0, 0, "%.*s%08x", 1, s, 1);
  if (7 < n && n < 10) return;
  __builtin_abort ();
}

Reply via email to