public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/102934] New: missing warning passing address of first member to free()
@ 2021-10-25 17:19 msebor at gcc dot gnu.org
  2021-10-25 17:20 ` [Bug middle-end/102934] " msebor at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: msebor at gcc dot gnu.org @ 2021-10-25 17:19 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 102934
           Summary: missing warning passing address of first member to
                    free()
           Product: gcc
           Version: 12.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: ---

GCC diagnoses the first invalid call to free() below but fails to diagnose the
second.  The problem is due to the warning using Object Size Type 0 (whole
objects) rather than 1 (subobjects) to determine the identity of the object
being freed.

$ cat z.c && gcc -O2 -S -Wall z.c
struct A { int i, a[2]; };

void f (struct A  *p)
{
  __builtin_free (p->a);   // -Wfree-nonheap-object (good)
}

struct B { int a[2], j; };

void g (struct B *p)
{
  __builtin_free (p->a);   // missing warning
}

z.c: In function ‘f’:
z.c:5:3: warning: ‘__builtin_free’ called on pointer ‘p’ with nonzero offset 4
[-Wfree-nonheap-object]
    5 |   __builtin_free (p->a);   // -Wfree-nonheap-object (good)
      |   ^~~~~~~~~~~~~~~~~~~~~

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

* [Bug middle-end/102934] missing warning passing address of first member to free()
  2021-10-25 17:19 [Bug middle-end/102934] New: missing warning passing address of first member to free() msebor at gcc dot gnu.org
@ 2021-10-25 17:20 ` msebor at gcc dot gnu.org
  2021-10-26  7:07 ` rguenth at gcc dot gnu.org
  2022-01-26 17:19 ` msebor at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: msebor at gcc dot gnu.org @ 2021-10-25 17:20 UTC (permalink / raw)
  To: gcc-bugs

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

Martin Sebor <msebor at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |ASSIGNED
     Ever confirmed|0                           |1
           Assignee|unassigned at gcc dot gnu.org      |msebor at gcc dot gnu.org
           Keywords|                            |diagnostic
   Last reconfirmed|                            |2021-10-25

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

* [Bug middle-end/102934] missing warning passing address of first member to free()
  2021-10-25 17:19 [Bug middle-end/102934] New: missing warning passing address of first member to free() msebor at gcc dot gnu.org
  2021-10-25 17:20 ` [Bug middle-end/102934] " msebor at gcc dot gnu.org
@ 2021-10-26  7:07 ` rguenth at gcc dot gnu.org
  2022-01-26 17:19 ` msebor at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-10-26  7:07 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
But the second is valid?  p->a is just an obfuscated way to write p.

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

* [Bug middle-end/102934] missing warning passing address of first member to free()
  2021-10-25 17:19 [Bug middle-end/102934] New: missing warning passing address of first member to free() msebor at gcc dot gnu.org
  2021-10-25 17:20 ` [Bug middle-end/102934] " msebor at gcc dot gnu.org
  2021-10-26  7:07 ` rguenth at gcc dot gnu.org
@ 2022-01-26 17:19 ` msebor at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: msebor at gcc dot gnu.org @ 2022-01-26 17:19 UTC (permalink / raw)
  To: gcc-bugs

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

Martin Sebor <msebor at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Assignee|msebor at gcc dot gnu.org          |unassigned at gcc dot gnu.org
             Status|ASSIGNED                    |NEW

--- Comment #2 from Martin Sebor <msebor at gcc dot gnu.org> ---
I'm not working on this anymore.

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

end of thread, other threads:[~2022-01-26 17:19 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-25 17:19 [Bug middle-end/102934] New: missing warning passing address of first member to free() msebor at gcc dot gnu.org
2021-10-25 17:20 ` [Bug middle-end/102934] " msebor at gcc dot gnu.org
2021-10-26  7:07 ` rguenth at gcc dot gnu.org
2022-01-26 17:19 ` 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).