From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id AF5683858C39; Mon, 17 Jul 2023 20:42:19 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AF5683858C39 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1689626539; bh=72rkqAB5ipxKZa2+gwwmsGvuOz4Y7GQgA9zeIYcQrD4=; h=From:To:Subject:Date:In-Reply-To:References:From; b=fNpwbFXtYrxb6BzlhYJOGjF1kbjBEpc6fUP1VQeCurrWM/paffiKSUuKu6EArEUPd Dyf61TnMUPcYXrrJDUUvkzFLqfHea6Dk4unEGM2MsLKb1yQdOBzCp2YgRMXOOX3vv0 JDjfOeIQRX3CgEpsiIaJaO5cRhW4eX7ESyCACK8A= From: "qinzhao at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/109557] __builtin_dynamic_object_size() does not work for simple testing case Date: Mon, 17 Jul 2023 20:42:18 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: middle-end X-Bugzilla-Version: 13.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: qinzhao at gcc dot gnu.org X-Bugzilla-Status: RESOLVED X-Bugzilla-Resolution: INVALID 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: 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=3D109557 --- Comment #8 from qinzhao at gcc dot gnu.org --- with the following slightly modified testing case, the same issue: #include #include struct P { int k; int x[10];=20 } *p; void store(int a, int b)=20 { p =3D (struct P *)malloc (sizeof (struct P)); p->k =3D a; p->x[b] =3D 0; assert (__builtin_dynamic_object_size (p, 1) =3D=3D sizeof (struct P)); return; } int main() { store(7, 7); assert (__builtin_dynamic_object_size (p, 1) =3D=3D sizeof (struct P)); free (p); } [opc@qinzhao-ol8u3-x86 109557]$ sh t /home/opc/Install/latest/bin/gcc -O -fsanitize=3Dbounds -fsanitize=3Dobject= -size -fstrict-flex-arrays=3D3 -fdump-tree-all t.c a.out: t.c:20: main: Assertion `__builtin_dynamic_object_size (p, 1) =3D=3D= sizeof (struct P)' failed. t: line 19: 629958 Aborted (core dumped) ./a.out=