From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 90D363858D35; Tue, 27 Jun 2023 04:18:48 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 90D363858D35 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1687839528; bh=YKTkQsAlIDBiaUwMEEwaM9dNHhnXpIGrOYUK8i67Xf0=; h=From:To:Subject:Date:From; b=sWoUYSAJhjEoBPUNm5wJYEDRuUpRZKqVP3HcFKgltkzpuJ+hFW7EWCsuW8HGZNWV1 tS4h9BrX9tCr18ICKfYhlcg8gckq8/H+gOUXEFa/YOgryn+WuRSM98ACF9Pz1S4cpK G1N+BJWIx3fA4EBo0Uo50f/qrp+9jXFo7hDdpuno= From: "alexhenrie24 at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug analyzer/110426] New: Missing buffer overflow warning with function pointer that has the alloc_size attribute Date: Tue, 27 Jun 2023 04:18:48 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: analyzer X-Bugzilla-Version: 13.1.1 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: alexhenrie24 at gmail dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: dmalcolm 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 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D110426 Bug ID: 110426 Summary: Missing buffer overflow warning with function pointer that has the alloc_size attribute Product: gcc Version: 13.1.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: analyzer Assignee: dmalcolm at gcc dot gnu.org Reporter: alexhenrie24 at gmail dot com Target Milestone: --- I expected to get a warning when compiling this program with -fanalyzer: #include extern void* (*my_alloc)(size_t) __attribute__ ((alloc_size (1))); int main(void) { int *x =3D my_alloc(1); x[0] =3D 0; // buffer overflow! return 0; } There is a warning if I call malloc instead of my_alloc.=