From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 574C938930DD; Mon, 9 Aug 2021 10:34:00 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 574C938930DD From: "eggert at cs dot ucla.edu" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/101829] New: problems with inline + __attribute__ ((malloc (deallocator))) Date: Mon, 09 Aug 2021 10:33:59 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: middle-end X-Bugzilla-Version: 11.2.1 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: eggert at cs dot ucla.edu X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 09 Aug 2021 10:34:00 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D101829 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 Gn= ulib 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 res= ult in apparent mismatches, this form of attribute @code{malloc} is not accepte= d on inline functions." This has caused problems for us, as many of our functions are naturally inl= ine and are allocators or deallocators. As Bruno Haible wrote in : "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.=