public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/108115] New: spurious pointer used after realloc warning
@ 2022-12-15  0:13 tony@develop-help.com
  2022-12-15  0:37 ` [Bug middle-end/108115] " pinskia at gcc dot gnu.org
  2022-12-15  0:40 ` pinskia at gcc dot gnu.org
  0 siblings, 2 replies; 3+ messages in thread
From: tony@develop-help.com @ 2022-12-15  0:13 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 108115
           Summary: spurious pointer used after realloc warning
           Product: gcc
           Version: 12.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: tony@develop-help.com
  Target Milestone: ---

Created attachment 54097
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=54097&action=edit
Code that demonstrates the warning

gcc 12.0.1 produces a spurious warning when an access to an integer copy of a
pointer is accessed within an unrelated runtime conditional.

With the attachment:

$ /opt/gcc-12.1.0/bin/gcc -c -std=c99 -O2 -Wall -Wextra gcc-20507-simple.c 
gcc-20507-simple.c: In function ‘my_realloc’:
gcc-20507-simple.c:13:15: warning: pointer ‘p’ may be used after ‘realloc’
[-Wuse-after-free]
   13 |     uintptr_t u = (uintptr_t)p;
      |               ^
gcc-20507-simple.c:15:18: note: call to ‘realloc’ here
   15 |     void *newp = realloc(p, newsz);
      |                  ^~~~~~~~~~~~~~~~~
$ /opt/gcc-12.1.0/bin/gcc -c -std=c99 -O2 -Wall -Wextra -DDEBUG=1
gcc-20507-simple.c 
(no diagnostics)

Note that p is not used after the realloc() in either case.

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

* [Bug middle-end/108115] spurious pointer used after realloc warning
  2022-12-15  0:13 [Bug c/108115] New: spurious pointer used after realloc warning tony@develop-help.com
@ 2022-12-15  0:37 ` pinskia at gcc dot gnu.org
  2022-12-15  0:40 ` pinskia at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-12-15  0:37 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
           See Also|                            |https://gcc.gnu.org/bugzill
                   |                            |a/show_bug.cgi?id=104215
         Resolution|---                         |DUPLICATE

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
A dup of bug 106119.

*** This bug has been marked as a duplicate of bug 106119 ***

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

* [Bug middle-end/108115] spurious pointer used after realloc warning
  2022-12-15  0:13 [Bug c/108115] New: spurious pointer used after realloc warning tony@develop-help.com
  2022-12-15  0:37 ` [Bug middle-end/108115] " pinskia at gcc dot gnu.org
@ 2022-12-15  0:40 ` pinskia at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-12-15  0:40 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2022-12-15
             Status|RESOLVED                    |NEW
         Resolution|DUPLICATE                   |---
     Ever confirmed|0                           |1
           See Also|                            |https://gcc.gnu.org/bugzill
                   |                            |a/show_bug.cgi?id=106119

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Maybe not exactly a dup. But what is happening is we are sinking the cast to
the conditional which moves it across the free.

But definitely related to PR 106119 and PR 104215 .

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

end of thread, other threads:[~2022-12-15  0:40 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-15  0:13 [Bug c/108115] New: spurious pointer used after realloc warning tony@develop-help.com
2022-12-15  0:37 ` [Bug middle-end/108115] " pinskia at gcc dot gnu.org
2022-12-15  0:40 ` 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).