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

            Bug ID: 90735
           Summary: missing location in -Wreturn-local-addr on a function
                    with two return statements
           Product: gcc
           Version: 9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: middle-end
          Assignee: unassigned at gcc dot gnu.org
          Reporter: msebor at gcc dot gnu.org
  Target Milestone: ---

The -Wreturn-local-addr warning is often missing location information when
issued for one of two (or more) return statements in a function involving
conditionals.  For example:

$ cat a.c && gcc -O2 -S -Wall -Wextra a.c
extern int a[], b[];

int* f (int i, int j)
{
  int c;
  int *p = i < 0 ? a : b;
  if (*p)
    return p;
  if (j < 0)
    p = &c;

  return p;
}
a.c: In function ‘f’:
cc1: warning: function may return address of local variable
[-Wreturn-local-addr]
a.c:5:7: note: declared here
    5 |   int c;
      |       ^

Reply via email to