From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 1F0C83858CDB; Mon, 28 Nov 2022 08:40:19 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1F0C83858CDB DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1669624819; bh=Zz3ARR1YJQ3DXvIsml5CIdkoozrJWNEzbSRV8IhIYEM=; h=From:To:Subject:Date:From; b=t31FfHvkHIpAPsenFAaktA//ET7ZHusynvQiEy0+YcRl3xq3zI9qYaMD/a6S3hMqf KNJsco+0pxsRxuUXBNuzBqhIxQ5oKcWQG7KfX+MPDBvItYUMqP/5LiBeq5HZfS6eVs vElFkEbYWpMzFigzyf5cO1ziE851YMMPlIZPAeRw= From: "shaohua.li at inf dot ethz.ch" To: gcc-bugs@gcc.gnu.org Subject: [Bug sanitizer/107893] New: gcc trunk at -O0 (UBSan) misses a Null-pointer-dereference Date: Mon, 28 Nov 2022 08:40:18 +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=3D107893 Bug ID: 107893 Summary: gcc trunk at -O0 (UBSan) misses a Null-pointer-dereference 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, `gcc-trunk -O0 -fsanitize=3Dundefined=20 -fno-sanitize-recover=3Dall` misses the NULL-pointer-dereference, while `gcc-trunk -Ox -fsanitize=3Daddress -fno-sanitize-recover=3Dall` (x=3D1, 2= , 3, or s) can detect it. I checked gcc8/9/10/11/12 and they all have this issue. clang can detect it at all optimization levels. Compiler explorer: https://godbolt.org/z/85qfdccse % cat a.c int main() { int *a =3D 0; (a[1] | a[0]) >> 056; } % % gcc-tk -O0 -fsanitize=3Dundefined -fno-sanitize-recover=3Dall -w a.c &&./= a.out Segmentation fault % gcc-tk -O1 -fsanitize=3Dundefined -fno-sanitize-recover=3Dall -w a.c &&./= a.out a.c:3:13: runtime error: load of null pointer of type 'int' %=