public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/104761] New: [12 Regression] False positive -Wdangling-pointer warning on NetworkManager since r12-6606
@ 2022-03-02 15:19 jakub at gcc dot gnu.org
  2022-03-02 15:19 ` [Bug middle-end/104761] " jakub at gcc dot gnu.org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: jakub at gcc dot gnu.org @ 2022-03-02 15:19 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 104761
           Summary: [12 Regression] False positive -Wdangling-pointer
                    warning on NetworkManager since r12-6606
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: middle-end
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jakub at gcc dot gnu.org
  Target Milestone: ---

With -O0 -Wdangling-pointer or -O2 -Wall (the latter is a regression) the
following testcase emits 2 false positive warnings:
nm-shared-utils.i: In function ‘test’:
nm-shared-utils.i:21:40: warning: dangling pointer to ‘error’ may be used
[-Wdangling-pointer=]
   21 |           corge (qux (addrbin.s), error->t);
      |                                        ^~
nm-shared-utils.i:18:45: note: ‘error’ declared here
   18 |       __attribute__((__cleanup__ (bar))) T *error = (T *) 0;
      |                                             ^~~~~
nm-shared-utils.i:21:11: warning: dangling pointer to ‘addrbin’ may be used
[-Wdangling-pointer=]
   21 |           corge (qux (addrbin.s), error->t);
      |           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
nm-shared-utils.i:13:5: note: ‘addrbin’ declared here
   13 |   S addrbin;
      |     ^~~~~~~
Commenting out the endless loop makes it go away.
Started with the addition of -Wdangling-pointer in
r12-6606-g9d6a0f388eb048f8d87f.

typedef struct { unsigned int s; } S;
int foo (S *);
typedef struct { char *t; } T;
void garply (T *);
static inline void bar (T **v) { if (*v) garply (*v); }
int baz (T **);
const char *qux (unsigned);
void corge (const char *, const char *);

int
test (int x)
{
  S addrbin;
  if (foo (&addrbin) != 1)
    return 0;
  if (x == 2)
    {
      __attribute__((__cleanup__ (bar))) T *error = (T *) 0;
      if (!baz (&error))
        {
          corge (qux (addrbin.s), error->t);
          for (;;)
            ;
        }
    }
  return 1;
}

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2022-03-03 21:02 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-02 15:19 [Bug middle-end/104761] New: [12 Regression] False positive -Wdangling-pointer warning on NetworkManager since r12-6606 jakub at gcc dot gnu.org
2022-03-02 15:19 ` [Bug middle-end/104761] " jakub at gcc dot gnu.org
2022-03-02 15:51 ` jakub at gcc dot gnu.org
2022-03-02 16:07 ` jakub at gcc dot gnu.org
2022-03-02 20:35 ` msebor at gcc dot gnu.org
2022-03-02 23:16 ` [Bug middle-end/104761] [12 Regression] bogus -Wdangling-pointer with cleanup and infinite loop msebor at gcc dot gnu.org
2022-03-03 21:02 ` cvs-commit at gcc dot gnu.org
2022-03-03 21:02 ` msebor at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).