public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/110546] New: Function clone not treated as valid allocator with -Wmismatched-dealloc
@ 2023-07-04 14:48 fw at gcc dot gnu.org
  2023-07-04 15:24 ` [Bug tree-optimization/110546] " pinskia at gcc dot gnu.org
  2023-07-10  0:32 ` pinskia at gcc dot gnu.org
  0 siblings, 2 replies; 3+ messages in thread
From: fw at gcc dot gnu.org @ 2023-07-04 14:48 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 110546
           Summary: Function clone not treated as valid allocator with
                    -Wmismatched-dealloc
           Product: gcc
           Version: 13.1.1
            Status: UNCONFIRMED
          Keywords: diagnostic
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: fw at gcc dot gnu.org
            Blocks: 99715
  Target Milestone: ---

If compiled with -Wall -Werror -O3, the code below produces the following
diagnostic:

t.c: In function ‘f’:
t.c:16:3: error: ‘dealloc’ called on pointer returned from a mismatched
allocation function [-Werror=mismatched-dealloc]
   16 |   dealloc (alloc (1));
      |   ^~~~~~~~~~~~~~~~~~~
t.c:16:3: note: returned from ‘alloc.constprop’
   16 |   dealloc (alloc (1));
      |   ^~~~~~~~~~~~~~~~~~~


I believe this happens because the compiler does not recognize that
alloc.constprop is a valid allocation function for alloc because its internal
name is distinct from the expected name dealloc.


extern void *alloc0 (int n);

void dealloc (void *);

void *__attribute__ ((noinline, malloc (dealloc, 1)))
alloc (int n)
{
  if (n <= 0)
    __builtin_abort ();
  return alloc0 (n);
}

void
f (void)
{
  dealloc (alloc (1));
}


Referenced Bugs:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99715
[Bug 99715] [meta-bug] bogus/missing Wmismatched-dealloc warnings

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

* [Bug tree-optimization/110546] Function clone not treated as valid allocator with -Wmismatched-dealloc
  2023-07-04 14:48 [Bug tree-optimization/110546] New: Function clone not treated as valid allocator with -Wmismatched-dealloc fw at gcc dot gnu.org
@ 2023-07-04 15:24 ` pinskia at gcc dot gnu.org
  2023-07-10  0:32 ` pinskia at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-07-04 15:24 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
      Known to fail|                            |11.1.0, 12.1.0
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2023-07-04
     Ever confirmed|0                           |1

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Confirmed.


>I believe this happens because the compiler does not recognize that alloc.constprop is a valid allocation function

No that is not the issue. This code to figure out the mistmatch seems too
complex for my liking.

The attribute is still there:
__attribute__((malloc (deallocD.2759, 1), noinline))
voidD.53 * alloc.constpropD.2777 ()

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

* [Bug tree-optimization/110546] Function clone not treated as valid allocator with -Wmismatched-dealloc
  2023-07-04 14:48 [Bug tree-optimization/110546] New: Function clone not treated as valid allocator with -Wmismatched-dealloc fw at gcc dot gnu.org
  2023-07-04 15:24 ` [Bug tree-optimization/110546] " pinskia at gcc dot gnu.org
@ 2023-07-10  0:32 ` pinskia at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-07-10  0:32 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |andres at anarazel dot de

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
*** Bug 110609 has been marked as a duplicate of this bug. ***

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

end of thread, other threads:[~2023-07-10  0:32 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-04 14:48 [Bug tree-optimization/110546] New: Function clone not treated as valid allocator with -Wmismatched-dealloc fw at gcc dot gnu.org
2023-07-04 15:24 ` [Bug tree-optimization/110546] " pinskia at gcc dot gnu.org
2023-07-10  0:32 ` 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).