------- Comment #5 from pinskia at gcc dot gnu dot org  2006-12-02 05:52 -------
The main issue I have emitting a warning here is that it will produce a bunch
of false positives for an example:

static int f(int *a)
{
  if (a)
    return *a;
  return -1;
}

int g(int *a, int c) __attribute__((nonnull(1) ));

int g(int *a, int c)
{
  if (c)
    return f(a);
  return -1; 
}

int h(int *a, int c)
{
  if (c)
    return f(a);
  return -1; 
}

Or even f is a define:

#define f(a) ({int *b_ = a;  int t = -1; if(b_) t = *b_; t;})

Also we don't want to warn for:

int g(int *a, int c) __attribute__((nonnull(1) ));
int *x;
int g(int *a, int c)
{
  if (!c) a = x
  if (a)  return *a;
  return c;
}

This shows how very fragile this warning will have to be to be able to not to
warn in those cases.  The unsigned warning is very fragile when it comes to
macros (and templates) also but it is not as fragile as this warning as it is
not flow sensative.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30043

Reply via email to