From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 5F79D3858C66; Tue, 7 Mar 2023 08:51:53 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5F79D3858C66 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1678179113; bh=79iq7P1QYHrC0DEgBqPK0h0xEhiHuVpt6VI9sTrVvT0=; h=From:To:Subject:Date:From; b=LkxmQJ5nXmMAz1nyHavNsudmwSnZVjeP5RkARLX3EVQT7Wlj9xD+V85Wj8jo7d+5H 7WznsK5a+Umaga1bQDpiklF4QpcgayNFdbOY3wHtTpjZiovCKeC++ekzF1lhwz2E6U ufiuePrHAhJG9IFGl6lBAvTaRTQjDt+U1Blturak= From: "shaohua.li at inf dot ethz.ch" To: gcc-bugs@gcc.gnu.org Subject: [Bug sanitizer/109050] New: UBsan failed to detect out-of-bound at -O0/1/2/s Date: Tue, 07 Mar 2023 08:51:53 +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.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: shaohua.li at inf dot ethz.ch 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=3D109050 Bug ID: 109050 Summary: UBsan failed to detect out-of-bound at -O0/1/2/s Product: gcc Version: 13.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: sanitizer Assignee: unassigned at gcc dot gnu.org Reporter: shaohua.li at inf dot ethz.ch 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: --- For the following code, UBsan failed to detect the out-of-bound access at a= ll opt levels. Clang can detect it at all opt levels. Compiler explorer: https://godbolt.org/z/TK35hvPrK % cat a.c long a; int b; int main() { int c[4]=3D{0, 1, 2, 3}; a =3D 0; for (; a <=3D 2; a++) c[a - 9806816] |=3D b; } % % gcc-tk -O0 -fsanitize=3Dundefined a.c && ./a.out % % gcc-tk -O1 -fsanitize=3Dundefined a.c && ./a.out % % clang -O1 -fsanitize=3Dundefined a.c && ./a.out /a.c:7:5: runtime error: index -9806816 out of bounds for type 'int[4]' ... % gcc-tk -v Using built-in specs. COLLECT_GCC=3Dgcc-tk COLLECT_LTO_WRAPPER=3D/zdata/shaoli/compilers/ccbuilder-compilers/gcc-7e9dd= 9de169034810b92d47bf78284db731fa5da/libexec/gcc/x86_64-pc-linux-gnu/13.0.1/= lto-wrapper Target: x86_64-pc-linux-gnu Configured with: ../configure --disable-multilib --disable-bootstrap --enable-languages=3Dc,c++ --prefix=3D/zdata/shaoli/compilers/ccbuilder-compilers/gcc-7e9dd9de16903481= 0b92d47bf78284db731fa5da Thread model: posix Supported LTO compression algorithms: zlib gcc version 13.0.1 20230221 (experimental) (GCC) %=