From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 87FFB3858C54; Mon, 28 Nov 2022 09:05:26 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 87FFB3858C54 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1669626326; bh=zoUVE6kK29q2GyrzTgYMmVhEk/ouNy78UY6ngfEFLE0=; h=From:To:Subject:Date:In-Reply-To:References:From; b=KkXyHmURpoeU7pvgXe97TubQCBPS0qoTgg5A5cxv2lS3CxfdtybN5cL+EJiH2K5td UGHOu1VwlyUzrwS3n+79qBhehLj46Hq9hVV0Tf2bAY1LqrnBXSM6r/TRs3loqWYfI4 7FZidZYqBva6H8J2PRJfDZQ8lP4lt0CEhJ3b2Fw0= From: "shaohua.li at inf dot ethz.ch" To: gcc-bugs@gcc.gnu.org Subject: [Bug sanitizer/107893] gcc trunk at -O0 (UBSan) misses a Null-pointer-dereference Date: Mon, 28 Nov 2022 09:05:25 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed 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: 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=3D107893 --- Comment #4 from Li Shaohua --- (In reply to Richard Biener from comment #3) > That is, >=20 > int main() { > int *a =3D 0; > (a[0] | a[1]) >> 056; > } >=20 > works at -O0: >=20 > t.c:3:6: runtime error: load of null pointer of type 'int' Yes, the a[1] access caused the segfault. For clang's UBsan, it emits an er= ror message for a[1]: a.c:3:5: runtime error: applying non-zero offset 4 to null pointer SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior a.c:3:5 in Is there a way for gcc's UBsan to warn such errors?=