From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 762B03858D35; Tue, 27 Dec 2022 08:11:05 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 762B03858D35 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1672128665; bh=p57XTZ0CKut+xVCQ3NOQjtbAsgHvL1cwdsBiw1IcrFM=; h=From:To:Subject:Date:In-Reply-To:References:From; b=TyLN0aqqVtIUdngLqOhUjvssq1LEIrSqWG8Me1wH/CkbVYRZm4/uUxx+hYnfO3cKE AJmv6KPPWE2FUq9rJo/BYrjcUbS4ErwO/NIPZeC4eE9XJeudjM3OALf2tWpjo3g5KT 11qwBxhJsWGbROBtroW5/ZdVMY0PDJ9U/gDJEtm0= From: "pinskia at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/108231] malloc and cleanup attributes vs extern "C" in a namespace and global and using of one in the namespace in the global one and the builtin free Date: Tue, 27 Dec 2022 08:11:05 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 12.2.0 X-Bugzilla-Keywords: rejects-valid X-Bugzilla-Severity: normal X-Bugzilla-Who: pinskia at gcc dot gnu.org X-Bugzilla-Status: NEW 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: short_desc Message-ID: In-Reply-To: References: 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 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D108231 Andrew Pinski changed: What |Removed |Added ---------------------------------------------------------------------------- Summary|malloc attribute vs extern |malloc and cleanup |"C" in a namespace and |attributes vs extern "C" in |global and using of one in |a namespace and global and |the namespace in the global |using of one in the |one and the builtin free |namespace in the global one | |and the builtin free --- Comment #3 from Andrew Pinski --- Here is another example of the same issue but with cleanup attribute instea= d: ``` namespace std { extern "C" int printf (const char*, ...); } using std::printf; extern "C" int printf (const char*, ...); void foo (const char *) { printf ("%s\n", __PRETTY_FUNCTION__); } void bar () { const char a __attribute__ ((cleanup (printf))) =3D 0; printf ("%s calling ", __PRETTY_FUNCTION__); foo (&a); printf ("cleanup calling "); } int main () { bar (); } ``` Note if you order swap the order of declarations of printf it works. Same with free in the original testcase for malloc.=