public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/101829] New: problems with inline + __attribute__ ((malloc (deallocator)))
@ 2021-08-09 10:33 eggert at cs dot ucla.edu
  2021-08-09 12:52 ` [Bug middle-end/101829] " rguenth at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: eggert at cs dot ucla.edu @ 2021-08-09 10:33 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 101829
           Summary: problems with inline + __attribute__ ((malloc
                    (deallocator)))
           Product: gcc
           Version: 11.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: middle-end
          Assignee: unassigned at gcc dot gnu.org
          Reporter: eggert at cs dot ucla.edu
  Target Milestone: ---

We've recently started using __attribute__ ((malloc (deallocator))) with Gnulib
and ran into the problem that the GCC documentation in doc/extend.texi says
this:

"Since inlining one of the associated functions but not the other could result
in apparent mismatches, this form of attribute @code{malloc} is not accepted on
inline functions."

This has caused problems for us, as many of our functions are naturally inline
and are allocators or deallocators. As Bruno Haible wrote in
<https://lists.gnu.org/r/bug-gnulib/2021-08/msg00092.html>:

"The GCC documentation [1] says that the attribute 'malloc (deallocator, 1)'
does not work on inline functions. IMO, this restriction is not tenable in the
long run (because the semantics of a function don't depend on whether it is
inline or not, and because in C++ the majority of all functions is inline)."


We have resorted to merely adding comments to the functions in question. It
would be better if we could add the attributes, and then GCC can ignore them
when applied to inline functions. Alternatively, GCC could refuse to inline
such functions. Either would be preferable to the current situation.

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

end of thread, other threads:[~2021-08-12 20:32 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-09 10:33 [Bug middle-end/101829] New: problems with inline + __attribute__ ((malloc (deallocator))) eggert at cs dot ucla.edu
2021-08-09 12:52 ` [Bug middle-end/101829] " rguenth at gcc dot gnu.org
2021-08-09 15:58 ` hubicka at ucw dot cz
2021-08-12 20:32 ` 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).