public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug analyzer/116006] New: RFE: detect usage of pointers to local variables that are out of scope
@ 2024-07-19 16:48 dmalcolm at gcc dot gnu.org
  2024-07-19 17:06 ` [Bug analyzer/116006] " pinskia at gcc dot gnu.org
  0 siblings, 1 reply; 2+ messages in thread
From: dmalcolm at gcc dot gnu.org @ 2024-07-19 16:48 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 116006
           Summary: RFE: detect usage of pointers to local variables that
                    are out of scope
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: analyzer
          Assignee: dmalcolm at gcc dot gnu.org
          Reporter: dmalcolm at gcc dot gnu.org
  Target Milestone: ---

Consider e.g.:

struct A *extref = something;
...
for (int i = 0; i < n; i++)
{
        struct A intref = *extref;
        intref.memb = i;
        extref = &intref;
}

This is storing a pointer to local variable "intref" into extref.

I think we detect the case where someone tries to use *extref once the function
frame has been popped (via the poisoned_svalue machinery) but I don't think we
detect the case where the usage happens in the same function but outside the
scope of "intref".

Trying it out here: https://godbolt.org/z/6s9WMh53K but I can't seem to trigger
even the popped frame case

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

* [Bug analyzer/116006] RFE: detect usage of pointers to local variables that are out of scope
  2024-07-19 16:48 [Bug analyzer/116006] New: RFE: detect usage of pointers to local variables that are out of scope dmalcolm at gcc dot gnu.org
@ 2024-07-19 17:06 ` pinskia at gcc dot gnu.org
  0 siblings, 0 replies; 2+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-07-19 17:06 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2024-07-19
             Status|UNCONFIRMED                 |NEW
           Severity|normal                      |enhancement

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Confirmed. I though we had a warning about escaping local addresses but I can't
seem to get it to hit for this case.

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

end of thread, other threads:[~2024-07-19 17:06 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-07-19 16:48 [Bug analyzer/116006] New: RFE: detect usage of pointers to local variables that are out of scope dmalcolm at gcc dot gnu.org
2024-07-19 17:06 ` [Bug analyzer/116006] " pinskia 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).