From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id A2182385840F; Thu, 17 Mar 2022 11:25:14 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A2182385840F From: "marxin at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/104964] Wrong *** buffer overflow detected ***: terminated - acl Date: Thu, 17 Mar 2022 11:25:14 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Version: 12.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: marxin 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: priority 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 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: Thu, 17 Mar 2022 11:25:14 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D104964 Martin Li=C5=A1ka changed: What |Removed |Added ---------------------------------------------------------------------------- Priority|P1 |P3 --- Comment #4 from Martin Li=C5=A1ka --- All right, so this one is likely an invalid code: cat x.c #include #include #include struct bad_struct { struct { char s_str[1]; } i; }; struct good_struct { char s_str[1]; }; ssize_t size =3D 30; struct bad_struct *bad; struct good_struct *good; int main() { good =3D (struct good_struct *)malloc (sizeof(struct good_struct) + size); char *str =3D good->s_str; strcpy (str, "sparta"); bad =3D (struct bad_struct *)malloc (sizeof(struct bad_struct) + size); char *str2 =3D bad->i.s_str; strcpy (str2, "sparta"); return 0; } It shows the difference in between wrapped struct and not wrapped one.=