[Bug middle-end/104092] New: [12 Regression] Invalid -Wdangling-pointer warning after writes by calls

rsandifo at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Tue Jan 18 11:12:07 GMT 2022


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

            Bug ID: 104092
           Summary: [12 Regression] Invalid -Wdangling-pointer warning
                    after writes by calls
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: middle-end
          Assignee: unassigned at gcc dot gnu.org
          Reporter: rsandifo at gcc dot gnu.org
  Target Milestone: ---

Compiling the following testcase with -march=armv8.2-a+sve -O2 -Wall:

--------------------------------------------------------------------
#include <arm_sve.h>

svuint64_t bar(svbool_t pg, const uint64_t *addr) {
  return svget2(svld2_u64(pg, addr), 0);
}
--------------------------------------------------------------------

triggers:

foo.c:4:16: warning: using a dangling pointer to an unnamed temporary
[-Wdangling-pointer=]
    4 |   return svget2(svld2_u64(pg, addr), 0);
      |          ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
foo.c:4:16: note: unnamed temporary defined here
    4 |   return svget2(svld2_u64(pg, addr), 0);
      |          ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~

This is because the code looks only at gassigns when tracking whether
a clobber has been overwritten, so it misses assignments by calls.

This seems to be different from PR104076.


More information about the Gcc-bugs mailing list