From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id B1939385840C; Wed, 10 Jan 2024 08:11:30 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B1939385840C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1704874290; bh=LA3auELr8lZaI22+7kUvQH5L5r1uF4DvjWUh24cXYAY=; h=From:To:Subject:Date:From; b=At2O0vFIXnQc5qK2iAxm0j9N2kip6tg65JDIP2btRYgvqlylVuzsOndzRWUZlkiQC WLy1PespZwfM8a3BGd6JYqR6WD51sXNYtW7L7qCB3hlKUcEPAZHHegC8Z5LoxjaOAZ h/EHp9rFUQj5x/xJ7rbJqDrfXox13NzuQosNJ6AU= From: "marcandre.lureau at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug sanitizer/113304] New: zero-length array and bound checking error Date: Wed, 10 Jan 2024 08:11:29 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: sanitizer X-Bugzilla-Version: 13.2.1 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: marcandre.lureau at gmail dot com 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 cc 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=3D113304 Bug ID: 113304 Summary: zero-length array and bound checking error Product: gcc Version: 13.2.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: sanitizer Assignee: unassigned at gcc dot gnu.org Reporter: marcandre.lureau at gmail dot com CC: dodji at gcc dot gnu.org, dvyukov at gcc dot gnu.org, jakub at gcc dot gnu.org, kcc at gcc dot gnu.org, marxi= n at gcc dot gnu.org Target Milestone: --- gcc (GCC) 13.2.1 20231205 (Red Hat 13.2.1-6) gcc -fsanitize=3Dbounds-strict -lubsan test.c test.c:6:11: runtime error: index 3 out of bounds for type 'int [*]' typedef struct BN { int d[0]; } BN; void test(BN *foo) { foo->d[3] =3D 0; } int main(int argc, char *argv[]) { struct BN { int d[4]; } foo; test((BN *)&foo); return 0; } This coding style is used in bignum libraries, such as libtpms BN implementation. Is this incompatible with bounds-strict usage?=