public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/110609] New: Bogus -Wmismatched-dealloc when allocator defined & used in same TU w/ -fPIC -fno-semantic-interposition
@ 2023-07-10  0:11 andres at anarazel dot de
  2023-07-10  0:32 ` [Bug c/110609] " pinskia at gcc dot gnu.org
  2023-07-10 15:31 ` andres at anarazel dot de
  0 siblings, 2 replies; 3+ messages in thread
From: andres at anarazel dot de @ 2023-07-10  0:11 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 110609
           Summary: Bogus -Wmismatched-dealloc when allocator defined &
                    used in same TU w/ -fPIC -fno-semantic-interposition
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: andres at anarazel dot de
  Target Milestone: ---

Hi,

Whenever an allocator function annotated with attribute((malloc(freelike)) is
defined and used in the same translation unit and -fno-semantic-interposition
-fPIC are used, bogus mismatched alloc/free warnings ensue.

----
void somefree(int *);

__attribute__((__malloc__(somefree, 1)))
int *somealloc(void) {
  return 0;
}

void other(void) {
  int *v = somealloc();
  somefree(v);
}
---
gcc -Wmismatched-dealloc -fno-semantic-interposition -fPIC -o a.out -c fd.c.i

fd.c.i: In function ‘other’:
fd.c.i:10:3: warning: ‘somefree’ called on pointer returned from a mismatched
allocation function [-Wmismatched-dealloc]
   10 |   somefree(v);
      |   ^~~~~~~~~~~
fd.c.i:9:12: note: returned from ‘somealloc.localalias’
    9 |   int *v = somealloc();
      |            ^~~~~~~~~~~

This appears to happen with all versions supporting -Wmismatched-dealloc,
including today's git head at 3b007164b3e.

Regards,

Andres

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

* [Bug c/110609] Bogus -Wmismatched-dealloc when allocator defined & used in same TU w/ -fPIC -fno-semantic-interposition
  2023-07-10  0:11 [Bug c/110609] New: Bogus -Wmismatched-dealloc when allocator defined & used in same TU w/ -fPIC -fno-semantic-interposition andres at anarazel dot de
@ 2023-07-10  0:32 ` pinskia at gcc dot gnu.org
  2023-07-10 15:31 ` andres at anarazel dot de
  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=110609

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |DUPLICATE

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

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

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

* [Bug c/110609] Bogus -Wmismatched-dealloc when allocator defined & used in same TU w/ -fPIC -fno-semantic-interposition
  2023-07-10  0:11 [Bug c/110609] New: Bogus -Wmismatched-dealloc when allocator defined & used in same TU w/ -fPIC -fno-semantic-interposition andres at anarazel dot de
  2023-07-10  0:32 ` [Bug c/110609] " pinskia at gcc dot gnu.org
@ 2023-07-10 15:31 ` andres at anarazel dot de
  1 sibling, 0 replies; 3+ messages in thread
From: andres at anarazel dot de @ 2023-07-10 15:31 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Andres Freund <andres at anarazel dot de> ---
(In reply to Andrew Pinski from comment #1)
> Dup.
> 
> *** This bug has been marked as a duplicate of bug 110546 ***

Are they really the same? This bug happens at -O0 and requires -fPIC and
-fno-semantic-interposition, whereas #110546 requires -O3? I don't know enough
about gcc, so you probably are right...

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

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

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-10  0:11 [Bug c/110609] New: Bogus -Wmismatched-dealloc when allocator defined & used in same TU w/ -fPIC -fno-semantic-interposition andres at anarazel dot de
2023-07-10  0:32 ` [Bug c/110609] " pinskia at gcc dot gnu.org
2023-07-10 15:31 ` andres at anarazel dot de

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).